how to extract certain lines from a log file
Hi there
I want to extract some lines from a log file pertaining to a certain date and time frame. The log file is /var/log/messages and it's huge: 7.4 MB gzipped, or 973,367 lines. I would like to extract, say, Feb 11 between 5-6 AM and save in another file or even view it on the command line (like with vi or something) I tried "cat messages.1.gz | grep "Feb 11"" and it didn't do anything. What about for a certain date (Feb 11) and some other entry in the line, for instance, a certian IP address? grep Feb 11 | grep 192.168.1.123? :scratch: Thank you very much |
I think you should un-gzip it, that should do the trick :).
|
Hah, thanks.
I unzipped it then I tried "cat messages.1 | grep "Feb 11" > newfile" and it worked. |
For grepping through gzipped files use the 'zgrep' command. It basically has the same syntax with grep.
|
All times are GMT -5. The time now is 01:16 PM. |