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: shell
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
decimal value is not printing in bash?
I want to evaluate the expression and display the output correct to 3 decimal places i tried with below code but it is not working help me how to do that in bash. Answer With bc: Output: 17.928
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
How to cut string between two search patterns(including search patterns) from a file?
I have a file called applications.txt which contains the following data : The strings in this file contain hostnames which I would like to display as follows : Few of the above servers are UAT and few are PROD servers. As you see the host-names are sandwiched between two patterns: First pattern is -x (lowercase x only), Second pattern is
How do I escape spaces in file paths when iterating in a for loop with a shell script in Linux?
I am writing a shell script in Linux that takes a file path and iterates over all files in the path. When a file is found it performs some logic. If a folder is found the function calls itself passing the folder as an argument. It works well unless there is white space in the folder path. Answer Double quotes