Issue
I have a file that contains lines of the form:
( 1) 0 sec 730 usec
( 2) 0 sec 1 usec
( 3) 0 sec 1 usec
.
.
.
(998) 0 sec 1 usec
(999) 0 sec 0 usec
I would like to only display lines which contains more than 100 usec
I tried to use xargs but my attempts failed. I also tried to write a bash script with a while loop, storing my file inside an ARG variable. But I don't know how to make my while loop parse through every single lines of ARG...
How to do that in both ways please ? Thanks
Solution
Using awk
Match lines with 5 fields if the 4th field is greater than or equal to 100 or match lines with 6 fields if the 5th field is greater than or equal to 100.
awk '(NF==5 && $4>=100) || (NF==6 && $5>=100) {print $0}' src.dat
( 1) 0 sec 730 usec
src.dat contents:
( 1) 0 sec 730 usec
( 2) 0 sec 1 usec
( 3) 0 sec 1 usec
.
.
.
(998) 0 sec 1 usec
(999) 0 sec 0 usec
Answered By - j_b Answer Checked By - Mildred Charles (WPSolving Admin)