Skip to content

Tag: regex

Bash Scripting – REGEX to dump a file list

I have 4 files extensions as result of previous works, stored in the $SEARCH array, as follows : I want to issue one file list for each of the 4 above extension patterns, as follows, except for the case with 2 dots and 2 extensions (marked “NO”) : Obviously I spent hours on regex101 w/o success. I…

How to find only the lines that contain two consecutive vowels

how to find lines that contain consecutive vowels $ (filename) | sed ‘/[a*e*i*o*u]/!d’ Answer To find lines that contain consecutive vowels you should consider using Here, [aeiou]{2,} pattern matches 2 or more occurrences ({2,} is an interval quantifier with the minimum occurrence number set to 2)…

Unable to get the output using regex

This might be a silly one, but I’m unable to get the required output. I’ve a file named Abc_sfgf_kjwefgk.txt20180929_040845 in a directory. I’m trying to list the file using the command: ls -l Abc_sfgf_kjwefgk.txt[0-9]{8}_[0-9]{4} But it’s giving me error: ls: cannot access ‘Abc_…

Trouble writing bash sed command – regex match

I have a file full of garbage collection information that is irregular, some lines have extra information that I want to initially remove so I can then process the the file as a whole. Unfortunately the line has quite a few special characters and I am struggling with a sed command that manages to match the bi…

multi pattern in sed -n

I know there are quite a few questions asked on this topic. But I need help in a case basis.When i try to put more than 3 pattern in the option, i will get the error like that… i only want to print the words in the brackets.. here is the sed command and the output… thanks… sample output Answ…

dynamic string search in shell script

I have a string in shell script which is I need to find DS_BLS_max(sequence number).dat here DS_BLS_max(sequence number).dat=DS_BLS_739.dat Answer Output: DS_BLS_739.dat See: The Stack Overflow Regular Expressions FAQ

Rename part of filename using regex

I have a bunch of files where there is additional information in square brackets. I would like to rename them by removing that section. For example: Want to rename to: I tried playing with regex (and using the rename command) but without success. Does anybody know a way to have the rename command strip of onl…

linux find files with optional character in their name

suppose I have two files: ac and abc. I want to find a regex to match both files. Normally I would expect the following regex to work, but it never does: I have tried escaping or not the questionmark, this never seems to work. Normally in the regex documentations I have found; ? means: previous character repe…