Skip to content
Advertisement

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 also tried to

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) and [aeiou] is a bracket expression matching any char defined in it. The -n

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_sfgf_kjwefgk.txt[0-9]{8}_[0-9]{4}’: No such file or directory While, with this command:ls -l Abc_sfgf_kjwefgk.txt[0-9]*?_[0-9]*? It’s giving me the correct result.

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 bit I want to

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 Answer

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 only the part of “

Using sed (or any other tool) to remove the quotes in a json file

I have a json file I want to change it to i.e. convert the requestId from String to Integer. I have tried some ways, but none seem to work : Could someone help me out please? Answer Try or The main differences with your attempts are: Your regular expressions were looking for [0-9] between double quotes, and that’s a single

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 repeated 0 or 1

Advertisement