Any equivalent command using awk or grep?
sed -n "/^$(date --date='10 minutes ago' '+%b %_d %H:%M')/,\$p" /abc.log
Any equivalent command using awk or grep?
sed -n "/^$(date --date='10 minutes ago' '+%b %_d %H:%M')/,\$p" /abc.log
Try this:
awk -v tm="$(date --date="10 minutes ago" "+%b %_d %H:%M")" '$0 ~ "^"tm"*" {p++} p' /abc.log
---------- Post updated at 02:45 PM ---------- Previous update was at 02:43 PM ----------
or
awk "/^$(date --date="-10 min" "+%b %_d %H:%M")/{p++} p" /abc.log
cool. both seems to work
The "*"
is too many in the first sample.
Changing dates in log files ? .... why ?
This thread is about printing from a logfile, and so are the solutions.
I was just wondering about the needs, because it seems weird to me to alter the dates of a log file before printing it .
dude is not altering. its printing out the last 10 minutes of a log file. It will save energy to just print the last 10 minutes, then grep for a specific keyword. if you grep directly from a millions of lines for the period of 1 day, it will take ages to complete.