Page 1 of 1

How to fast check some archived log file

Posted: Fri Aug 26, 2022 1:57 pm
by isscbta
Logrotated log files are usually gzip-ed.
Fast way to 'cat' them is:

Code: Select all

zcat /var/log/somelog.2.gz
Fast way to 'grep' them:

Code: Select all

zgrep 'lookingfor' /var/log/somelog.2.gz
To zgrep all *.gz log files:

Code: Select all

zgrep 'lookingfor' /var/log/somelog.*.gz
--

If you need another processing command, for example 'exigrep', you can process .gz file through the 'zcat' pipe output:

Code: Select all

zcat /var/log/exim4/mainlog.2.gz | exigrep 'somedomain.com'
To zgrep all *.gz log files:

Code: Select all

zcat /var/log/exim4/mainlog.*.gz | exigrep 'somedomain.com'