I’m on Linux and I need to do an expr in order to match 6 digits with this range : 000001 to 999999 I’m stuck with ‘[0-9]{5}[1-9]’ but I can’t match numbers which end with 0 like 000010 I was thinking about ‘[0-9]{6}|?![0]{6}’ in order to eliminate “000000” How can I use ?! and/or are there any other solutions? EDIT
Tag: regex
Sed with special caracters
How can I replace this with sed ? I need to replace this: to Please note that I can’t sed the enabled to disabled because it’s not only used at this location in the input file. I tried this but it didn’t change anything but gave me no error: Answer You can just use the following sed command: CMD: Explanations:
How to do parsing of Elapsed time in seconds in linux
I want to do parsing of Elapsed time in seconds .Time formats given below: i’m getting values from systemctl status cassandra | awk ‘/(Active: active)/{print $9, $10,$11}’ Now storing it’s value in variable A,like now A has input as 3 day 18h or 3 day etc. More examples- A=3 day 18h or 3 day or 3h 15min or 3h or
+ Regular Expression not working in sed
Team, I have a file with data as mention below. Expected Output: I am using sed its not working . Please Let me know how to achieve the above mention output. Answer This might work for you (GNU sed): This method matches the numbers at the front of the string with strings appended to the end of the line and
Find and replace a word in all the files, which is falling under a searching criteria at Unix
I want to replace a word in all the files inside all the sub directories, which satisfy some criteria. Below is the elaborated situation. I have to replace all the Word having case insensitive word like {classy, CLASSY, cLassy ,..} to word “Vintage”. Also I only need to replace it where it have a case insensitive word “insert” or “INSERT”.
grep command in linux using ” in regex
I have the following linux cmd: The text i have is the following: Of course the output i want to have is: Why dont i have the correct output? Because of the ” required by the grep which mix with ” in my text? How to fix it? Answer You could use the following regex: Original poster provided a regex
Remove extra quotation marks in the grep output
the above cammand is used to get an http link example: www.224.ngrok.io but the output is say www.224.ngrok.io” How can I remove the extra ” at the end? I tried editing the ” from the grep command but it doesn’t work. Answer You can use positive lookahead: (?=”)matches the ” without making it part of the match.
Grep Regex: How to find multiple area codes in phone number?
I have a file: each line consist of a name, room number, house address, phone number. I want to search for the lines that have the area codes of either 404 or 202. I did “(404)|(202)” but it also gives me lines that had the numbers in the phone number in general instead of from area code, example: I do
Access the word in the file with grep
I have a conf file and I use grep to access the data in this file but not a very useful method for me. How can I just get the main word by search-term? I using: Print: I want: (without “export: “) How can I do that? Answer If you’re using GNU grep you can use PCRE and a lookbehind:
Regex is not checking some part of text
I’ve example file with data to analyze by egrep command: My regexp looks that: I wan’t to find only rows where [RM# {digits}] AND [IG# {digits}] but it returns like using OR and results looks following: Expected output is Answer Looks like you want to search for a line that should match two different strings in any order.. one way