How to fast check some archived log file

Post Reply
User avatar
isscbta
Team Member
Posts: 130
Joined: Mon Jul 19, 2021 1:41 am
Has thanked: 15 times
Been thanked: 3 times

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'

Tags:
Post Reply