Given a file of lines of the following format, I want to print those lines who have a time greater than X seconds.
2015-08-03 00:43:01, time taken to run = 10 seconds
How can I use a single line of awk to achieve this? Thanks!
Assuming that the number of seconds is always in the penultimate field, you could use something like this:
awk '$(NF-1) > 5' file NF is the number of fields, so $(NF-1) gets the value of the second to last field. If the value is greater than 5, the line is printed.
To use a shell variable instead, you can do something like this:
m=5 awk -v max="$m" '$(NF-1) > max' file