Both awk and sed can do this, but everything tried outputs nothing.
So, I have a huge log file from which I need to extract all events for a specific day.
Start pattern: "Tue Feb 24"
End pattern: "Wed Feb 25"
I used 'grep' to get the line numbers for start/end pattern like so:
Code:
grep -n "Tue Feb 24" /var/log/logfile.log |less
grep -n "Wed Feb 26" /var/log/logfile.log |less
This now works, I can actually get the content:
sed '29694592,29897297!d' /var/log/logfile.log |wc -l
202706
Of course I could be satisfied by this, but I know it can be done with a simple one-liner - I just can't get it right.
Here is what I've tried, none of them outputs anything:
Code:
awk '/"Tue Feb 24"/ { show=1 } show; /"Wed Feb 25"/ { show=0 }' /var/log/logfile.log
awk '/"Tue Feb 24"/,/"Wed Feb 25"/' /var/log/logfile.log
sed -n '/"Tue Feb 24"/,/"Wed Feb 25"/p' /var/log/logfile.log
sed -n -e '/"Tue Feb 24"/,/"Wed Feb 25"/p' /var/log/logfile.log
sed '/"Tue Feb 24"/,/"Wed Feb 25"/!d' /var/log/logfile.log
sed -e '/"Tue Feb 24"/,/"Wed Feb 25"/!d' /var/log/logfile.log
Extract from logfile, the line with date:
<log realm="RemoteServer" at="Tue Dec 02 01:32:19 CET 2014.599">