I've got a log file that I process as follows:
grep pattern /var/log/whatever.log | \
cut ... | sort | uniq -c | sort -rn | \
etc....
However, the log file is quite big, and records events from the beginning of the day. It's also appended to constantly. I'd like to only process the last next 10 minutes of the file.
So I'm looking for something like the following:
killafter 600 tail -f /var/log/whatever.log | stuff
Or, better yet (wait however long it takes to capture 1000 matching lines):
tail -f /var/log/whatever.log | grep pattern | stopafter -lines 1000 | stuff
Are there any tools that'll let me do this?
timeout
command. – Chris Davies Sep 09 '16 at 09:16