Skip to content

Tag: shell

Regex -> match a number between 000001 and 999999

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&#8221…

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:…

Running variable string match against grep search?

I’ve defined the variables here to shorten the logic a little. The wget works fine (downloads the correct file) and grepping for tar.gz works in the wget.log The issue is the match to another file! Basically, if it’s on a blacklist I want it to skip! Answer Use && to test if both of the gr…

reading file line by line in an infinite loop until break

I’m trying to implement an infinite loop bash script for reading in a file, doing something and check counter condition, when counter condition reaches 0 it breaks out of the infinite loop. I’ve tried several iteration and none has worked for me. Pseudo-code would be something line this.. Can anyo…

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…