Skip to main content

Questions tagged [pattern-matching]

The tag has no usage guidance.

3 votes
1 answer
139 views

To understand zmv ## patterns

This is zmv command to non-recursively replace any number of spaces with a single underscore (thanks to Stéphane Chazelas, who helped me with it): zmv -- '* *' '${f// ##/_}' And here is a command ...
jsx97's user avatar
  • 73
2 votes
1 answer
268 views

How is the correct syntax for a more complex case statement?

case "$1","$name" in -py | --python | --python3,*) if [[ "$name" =~ \..+$ ]]; then That doesn't catch stuff, which actually it should, like… USERNAME@HOSTNAME:~$ ...
futurewave's user avatar
-1 votes
5 answers
71 views

multiline grep search into separate files per occurence

I have a file as following: example.txt -1 15 1 0 0 11 -1.0000E+001 1.0000E+001 -1.0000E+001 2 0 0 11 1.0000E+001 1.0000E+001 ...
Honza S.'s user avatar
  • 101
0 votes
1 answer
51 views

Retrieve the Following Occurrence of the String 'PWD' Once the Given String is Located

Below is my sample test.log file export SQRDIR=/v/orahome/Middleware/Oracle/bin64 export OID=ap0092 export PWD=pass1 export FDPWD=pass1 export AP0085_PWD=pass1 export SVR=AFFPROD export ...
Ashar's user avatar
  • 511
1 vote
3 answers
346 views

awk print between lines when "/" is part of the name

I need to print lines between those that contain a "/" in the name. I tried with: awk '/+SOLUTION/ESTIMATES/,/-SOLUTION/ESTIMATES/' $F > fil$F and awk '/+SOLUTION"/"ESTIMATES/,/...
euge1780's user avatar
0 votes
0 answers
30 views

match files with regexp and move them

My problem is like this: The original folder "datasets to optimize" contains 1000s files whose names contain the following pattern: variable 2-3 dots or 1 dot with numbers, as in 1.87.184 ...
user1420275's user avatar
0 votes
4 answers
74 views

Wrap specific string with characters

For example, in a large file I might have: This is a /16 text file I'd like to change it to the following: This is a [[[/16]]]] text file Would like to match the exact string /16 Is there a way to ...
Proletariat's user avatar
2 votes
0 answers
57 views

Pattern list in bash extglob containing a / and a |

Here is a transcript of commands (and their output) that explains my problem: /tmp/example $ shopt -s cdspell on checkwinsize on cmdhist on complete_fullquote on direxpand ...
Happy Green Kid Naps's user avatar
1 vote
2 answers
48 views

replace both filename and filename's content relying solely on pattern found on the name-of-the-file

I'd like to know if it's possible to replace both filename.ext and a matched pattern inside its content regarding a pattern founded on the filename itself using sed (and grep also, maybe?). Let me ...
dAllARA's user avatar
  • 33
1 vote
1 answer
2k views

Searching for a pattern in a binary file using python script

I want to find repeated copies of the config section within the partition dump (binary file), using pattern and 'magic' header. The config section always starts with 202 '0xff' bytes followed by 4 ...
minto's user avatar
  • 535
0 votes
1 answer
82 views

Bash: Difference between "Pattern Matching" and "Filename Expansion" in the context of parameter expansions that do matching

Edit: Question ansewered by Gordon Davisson's comment I was reading the GNU Bash manual, and I noticed that there are basically three types of "Parameter expansion" that do pattern matching: ...
Sebastian Carlos's user avatar
3 votes
3 answers
730 views

Find files matching one pattern, but not another, using grep, awk or sed [duplicate]

I need to locate .php and .pl files that do not contain one string (e.g. aaa), but do contain another (e.g. bbb). I'm currently using this command: find /path/ \( -iname '*.php*' -or -name '*.pl*' \) -...
Krackout's user avatar
  • 2,742
4 votes
4 answers
691 views

grep multiple patterns with differing number of matching groups?

I'm trying to tally insertions and deletions from git diffs. I have the following, which when piped one or more strings of the form "4 files changed, 629607 insertions(+), 123 deletions(-)" ...
jawns317's user avatar
  • 143
1 vote
0 answers
69 views

does "find -name " matches the whole path or just the basename?

I was getting inconsistent results with pattern matching using -name, -iname, especially when looking for files -type f or directories type -d. Can someone explain under which circumstances -name ...
ricardo3889's user avatar
0 votes
3 answers
722 views

Glob pattern matching comma separated numbers

I want to write a glob pattern to match numbers separated by commas. What would the pattern be like? Here are some examples 5 5,8,13 Have started with the following, but there some problem with it, ...
Vera's user avatar
  • 1

15 30 50 per page
1
2 3 4 5
12