Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Easy browsing of compressed system logs UNIX
Mac OS X gzips all your old system.logs. If you just want to find something in them quickly, you can use the "zcat" utility:
zcat /var/log/system.log.3.gz
Pipe the output to 'grep' and 'more' for searches and paging:
zcat /var/log/system.log.3.gz | grep sudo | more
Type man zcat for more options.
    •    
  • Currently 3.00 / 5
  You rated: 3 / 5 (2 votes cast)
 
[4,451 views]  

Easy browsing of compressed system logs | 5 comments | Create New Account
Click here to return to the 'Easy browsing of compressed system logs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
(z)less is more
Authored by: ashevin on May 15, '02 10:24:08AM

Or you can use zless. It\'s a better pager than more, and it allows searching. I would still use the zcat <log> | grep <pattern> if I only wanted to see parts of the log. Using zless though, you can check the context if required. Also, use less as the pager in general. In this case less is more!

- Avi



[ Reply to This | # ]
(z)less is more
Authored by: patashnik on May 16, '02 05:26:36AM
For the more adventurous, read the manualpage for less (man less), and search for LESSOPEN; less can be made to open the most exotic filetypes, if you're willing to make a script which can translate those filetypes to plain text.

My lessopen-script (a Perl-script, in fact) can open things like HTML (by rendering the HTML to text with 'links'), PDF (pdftotext), all sorts of compressed files, archives, you name it. It can even retrieve urls with a commandline similar to:
less http://www.macosxhints.com/.

Indeed, less is superior to more :)

[ Reply to This | # ]
zgrep
Authored by: stefb on May 15, '02 10:29:40AM
zgrep sudo /var/log/system.log* | less does the same. Interesting about zgrep is that it does a grep on a "possibly compressed file" (quote from the man).

[ Reply to This | # ]
No man entry
Authored by: JohnnyMnemonic on May 15, '02 11:21:57AM

My terminal didn't know "man zcat" but, instead, "zcat -h" gave a help file. Why this is non-standard I dunno.



[ Reply to This | # ]
No man entry
Authored by: mervTormel on May 15, '02 02:31:06PM

some commands don't have man pages.



[ Reply to This | # ]