I have multiple files in a directory. I want to extract each line in all the files containing which has integer value greater than 45.
Currently, I am using :
grep "IO resumed after" *
Its displaying me all the files which this string "IO resumed after" I want to put one more parameter that will grep all the lines "IO resumed after [number >45] seconds"
Looks like i need to learn awk
until then i've got a bash solution. If seconds without decimal point then this:
while read line; do
number=${line//*after}
number=${number//seconds*}
((number>45)) && echo $line
done <<< $(grep "IO resumed after" *)
otherwise we have to use bc
:
while read line; do
number=${line//*after}
number=${number//seconds*}
case $(bc <<< "$number>45") in 1) echo "$line";; esac
done <<< $(grep "IO resumed after" *)