Skip to content
Advertisement

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” How can I use ?! and/or are there any other solutions? EDIT

Shell script: Redirect output of program to changing files

My goal: I would like to redirect the stdout output of my program foo to a changing output file depending on the running time of the program. The program foo itself is listening on a bsd socket for arriving packets and displays information contained in them. So essentially, after running the program foo for 10 minutes, I would like to

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:

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 grep commands succeed I’ve used

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 anyone show me how to implement something like the above in

Bash script that prints statistics about text files [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 4 years ago. Improve this question I am trying to write a Linux bash script that will

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

Advertisement