How can I do a grep count by using timestamp?
Example: If I have a file in which I search a value xyz everytime. The file gets updated regularly.
20121912-07:15:55 abc cbfr xyz
20121912-07:16:40 mni cbfr xyz
-----------
-----------
-----------
20121912-08:15:55 gty cbfr xyz
20121912-08:20:55 jui uio xyz
I want to find out the occurences of xyz after 20121912-08:15:55 which in this case should be 2.
Doing a grep -c "xyz" filename reads the entire file and gives the result. I want to do it after the last update or using a timestamp.
try this one-liner:
awk '$NF=="xyz"&&$1>="20121912-08:15:55"{x++;}END{print x}' file
                        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