Skip to main content

Questions tagged [pattern-matching]

Filter by
Sorted by
Tagged with
0 votes
2 answers
109 views

I'm trying to understand some subtle behavior of find and its -regex option I am trying to create symbolic links from files entitled slides_.*.pdf in folders that start with L1[0-6]. I tried the ...
mikemtnbikes's user avatar
1 vote
1 answer
71 views

Please look at this pattern replacement in parameter expansion: % zsh -c 'echo ${0/%.jpg/.jpeg}' toto.jpg toto.jpeg Replacement does not occur here: % zsh -c 'echo ${0/%.jpg/.jpeg}' toto.JPG toto.JPG ...
Pierre ALBARÈDE's user avatar
1 vote
1 answer
308 views

I'm new to sed, I have a string lightdm --session-child 14 21 the two numbers can change and I would remove everything after lightdm I tried various way but none worked sed 's/ --session-child*//' ...
klatls's user avatar
  • 53
2 votes
1 answer
141 views

The following code should demonstrate and help with testing inefficient Pattern Matching expressions in a Parameter Substitution for a newline-separated strings var vs. array. The goal is to achieve ...
fozzybear's user avatar
0 votes
4 answers
157 views

I'm trying to replace "}," by "}" from the last line of a file : My /etc/firefox/policies/policies.json file like this because I added the certificate lines using a for loop : $ ...
SebMa's user avatar
  • 2,473
3 votes
1 answer
409 views

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
  • 1,387
2 votes
1 answer
329 views

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
116 views

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
62 views

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
  • 527
1 vote
3 answers
389 views

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
4 answers
116 views

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
97 views

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
63 views

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
4k views

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
  • 595
0 votes
1 answer
140 views

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
1k views

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,897
4 votes
4 answers
796 views

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
139 views

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
1k views

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,373
0 votes
2 answers
77 views

I have a directory structure that follows this kind of pattern: - Dir 01 (Disc 1) \ - Dir 01 (Disc 1).iso - Dir 01 (Disc 2) \ - Dir 01 (Disc 2).iso - Dir 01 (Disc 3) \ - Dir 01 (Disc 3).iso - ...
bashing_pumpkins's user avatar
-2 votes
1 answer
68 views

I have 16 collections of 8 numbers (11 12 11 44 11 12 11 23) (12 21 11 44 11 12 11 23) (11 42 21 13 12 21 31 14) (11 42 21 13 12 21 11 34) and so on I want to find whether there are repetitions of ...
Vera's user avatar
  • 1,373
2 votes
2 answers
2k views

I have a txt file looking like this, 1:Ana:apple:08:00:wait 1:Joe:banana:08:30:wait 1:Oscar:orange:08:45:ready 1:Monica:apple:08:50:ready 1:Mark::orange:ready I have to find only the first line that ...
Claudio Del Prete's user avatar
0 votes
3 answers
865 views

I have a file with the following lines in i: .......... FROM ABCD_EXT .......... FROM HEG_EXT1 .......... from xyz_EXT .......... FROM abd_EXT2 ..........where QWT_EXT.SID=POI_EXT....
TexGC's user avatar
  • 31
0 votes
1 answer
266 views

I'm wondering what would be the best way (likely using grep or ack) to return lines containing unbalanced special character sets in a string? For example, if the string were: bqM#+t1U"OyBGhk]ozVG[...
irishwristwatch's user avatar
2 votes
2 answers
266 views

Say we have a file called "Hello World: The easiest program" and its name is saved in a variable called "title". I want to match this with glob pattern matching, but remove the ...
Rudi Österreicher's user avatar
1 vote
2 answers
64 views

vm0 host=10.182.35.1 controller=True vm1 host=10.182.35.2 controller=False solution=abc vm2 host=10.182.35.3 controller=True solution=abc vm3 host=10.182.37.4 controller=False solution=xyz vm4 host=10....
Madhavi Deshpande's user avatar
1 vote
2 answers
63 views

I'm beginner in bash scripts, but I try to delete everything in my pdb file (test.pdb) before REMARK time 20.00 and from REMARK time 30.00 to the end of this file. I'm using to this sed command, which ...
skywalker's user avatar
0 votes
1 answer
84 views

So I have files that need to remove/move/filter. All files have this pattern like this in a directory, let's say directory frames contain this pattern filename timestamp_in_nanosecond.jpg. And this is ...
Muhammad Ikhwan Perwira's user avatar
0 votes
2 answers
591 views

Sample markdown file: cat index.md # Abstract - To achieve [Work Life Balance](./WorkLifeBalance/WorkLifeBalance.md), first understand what it means and what are the requirements. - Develop right **[...
Porcupine's user avatar
  • 2,176
0 votes
1 answer
225 views

I have a bunch of files that contain strings similar to: Get<1>(abc) Get<2>(xyz) How can I recursively search for all files with the above pattern and remove everything before the first '(...
aWLW's user avatar
  • 133
7 votes
2 answers
3k views

My directory looks like this: $ ls total 0 -rw-r--r-- 1 user user 0 Jun 18 22:44 file0 -rw-r--r-- 1 user user 0 Jun 18 22:44 file1 -rw-r--r-- 1 user user 0 Jun 18 22:44 file2 -rw-r--r-- 1 user user 0 ...
rewire's user avatar
  • 111
0 votes
1 answer
199 views

I'm looking for a tool that gives me the total size on disk of certain folders and files. It should be able to unambiguously include or exclude items and all of their children (folders and files in it)...
ostrich's user avatar
  • 21
1 vote
2 answers
389 views

i have several patterns that include ** wildcard, let them be: foo/**/bar.xml foo/**/baz.xml and i have an example dirtree: $ tree foo/ foo/ └── deep ├── baz.xml └── even └── deeper ...
murison's user avatar
  • 163
-1 votes
2 answers
1k views

file1: G A 4 H B 3 I C 2 J D 1 file2: M H 6 N H 5 O K 4 P J 3 Q I 2 R I 1 S G 0 T L 1 Desired: M H 6 N H 5 P J 3 Q I 2 R I 1 S G 0 print only rows where $2 from file2 matches $1 from file1 I'm ...
Sollosa's user avatar
  • 2,009
0 votes
2 answers
425 views

I have in a directory files like this : booklet-001.pdf booklet-002.pdf booklet-003.pdf … booklet-997.pdf booklet-998.pdf booklet-999.pdf Then, I whant to match the files numbered from 079 to 256. ...
fauve's user avatar
  • 1,529
1 vote
0 answers
91 views

I store my MediaWiki 1.36.1 website with Skin:Timeless on NameCheap with a shared hosting environment with Cpanel file manager and SSH shell access. In my website, there is a certain footer element ...
searcher's user avatar
2 votes
1 answer
160 views

I have extended_glob set in .zshrc. this works as expected: [[ "value" = [a-z]* ]] && echo "globbed" Prints "globbed". But this does not: foo=[a-z]* [[ "...
toni rmc's user avatar
  • 123
5 votes
9 answers
1k views

I need to put one text inside another text. 1) I have a file with list of input values: A1 B2 C3 D4 E5 I have a wrapper pattern which should contain the text: $wgSpecialPageLockdown['INPUT_COMES_HERE'...
Lahor's user avatar
  • 123
8 votes
2 answers
4k views

Say I have two possible paths I want to list directories and files under on a Linux machine: /some/path1/ /some/path2/ If I do the following in tcsh, I get 0 exit code, if at least one of path1 or ...
shikhanshu's user avatar
0 votes
2 answers
154 views

I have an alias set as follows: alias ppp='prettier --write "**/*.js"' I want it also to do all my .ts files. I'm quite inept at wild card expressions sadly.
Peter Kellner's user avatar
7 votes
1 answer
339 views

While writing some awk code I was using the --lint option for gawk 4.1.0. To my surprise I get a warning warning: range of the form `[o-b]' is locale dependent but my code has only a foo-bar outside ...
U. Windl's user avatar
  • 1,777
4 votes
3 answers
3k views

In short, I instinctively wrote a command like this to find the two files prefix.ext and prefix_suffix.ext down a hierarchy find /some/path -type f -name 'prefix?(_suffix).zip' but it doesn't work. ...
Enlico's user avatar
  • 2,362
5 votes
1 answer
1k views

When navigating through Linux man pages, sometimes you need to query the meaning of flags like -p or -al in the man pages. The default text reader for man pages is less and I'm trying to use the / ...
Silver137's user avatar
  • 329
0 votes
1 answer
673 views

Let´s suppose I have the following file.txt: asiub sj abq b aia ainp oo test = 123d sub ,. aiba 87ab test = 129szs bq test = aqua ayqvq 133s I want to print only the lines of file.txt that contain ...
aaaaa's user avatar
  • 141
0 votes
1 answer
174 views

How can one recursively copy all files of a specific pattern (*.tpl) using rsync? Example: /etc/test.tpl /etc/dir/test.tpl /etc/dir/**/test.tpl
Spyros's user avatar
  • 165
1 vote
6 answers
1k views

I have a datafile, with dates in 2nd column # cat datafile -;20210106;-;-;-; -;20210112;-;-;-; -;20210112;-;-;-; -;20210112;-;-;-; ... -;20210217;-;-;-; -;20210217;-;-;-; -;20210217;-;-;-; -;20210217;-...
Sollosa's user avatar
  • 2,009
0 votes
0 answers
63 views

I would like to pick out lines from a file matching # Mode: org # can be any comment character for the programming language of the file. Rather than #, in could also be any of ; or !, with any ...
Vera's user avatar
  • 1,373
0 votes
2 answers
133 views

I have text file, and in it has a block that has pattern like below: # cat file Jit .... enabled=false Jit ..shoes.. From=2021-01-01 Jit ..gloves.. From=2021-01-01 so I want to change all of these ...
Sollosa's user avatar
  • 2,009
-1 votes
4 answers
3k views

I have a file in Linux which contains a line like : (memberOf=CN=Group1)(memberOf=CN=Group2)(memberOf=CN=Group3)(memberOf=CN=Group4) My goal is to populate the list of groups that is present in the ...
Deep's user avatar
  • 1
0 votes
1 answer
446 views

file1: pattern1 a b c end cmd=> cat file1 | sed -n '/pattern1/,/pattern2/p' output=> pattern1 a b c end How to not print the output if the second pattern does not match? Desired output: ...
Priyatharshini Ganesan's user avatar