Looking for #oneliners to scan some log files in #bash on #Linux that are automatically logrotated and gzipped along with the currently running log which is unzipped? This is a script that will print them all together so that you can pipe it to some custom grep/awk/sed logic to scan for information across your current and old logs simultaneously.
Put this logic in a file called xcat.sh (and of course give it execute permission):
for i in $@;do
[ ! -z “$(file -i $i | grep “gzip”)” ] && zcat $i || cat $i
Use it like so to scan all nginx logs:
$ ./xcat.sh /var/log/nginx/access.log*
“Fish and visitors smell in three days.” – Benjamin Franklin