I'm facing a problem while trying to grep
(filter) a logfile on the value of an integer.
logfile.log:
2014-11-16 21:22:15 8 10.133.23.9 PROXIED ...
2014-11-16 21:22:15 1 163.104.40.133 authentication_failed DENIED ...
2014-11-16 21:22:15 15 163.104.40.134 authentication_failed DENIED ...
2014-11-16 21:22:16 9 163.104.124.209 PROXIED ...
I have an int in column 3 : 8
, 1
, 15
, 9
.
I need to grep only if: value > 10
.
Something like:
cat logfile.log | grep {$2>10}
2014-11-16 21:22:15 15 163.104.40.134 authentication_failed DENIED ...
This should make!
$ awk '$3>10' file
2014-11-16 21:22:15 15 163.104.40.134 authentication_failed DENIED ...
With $3
we refer to the 3rd field, so that $3>10
means: lines having 3rd field bigger than 10. If this is accomplished, the condition is true and hence awk
performs its default behaviour: print the line.
You could of course say: print just an specific field, which you could by saying awk '$3>10 {print $1}' file
, for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With