Is there a commonly-installed Linux utility that will take a list of files and cat
or gzip -d
(==zcat
) them based on whether the file is compressed?
An example of where I just needed this is when I want to examine /var/log/messages
files, including both the logrotated ones (/var/log/messages-{date}.gz
) and the current file.
I'll likely add something like the following to my ~/.zshrc
:
catz () {
local file
for file ; do
case $file in
*gz*) gzip -d < $file ;;
*bz*) bzip -d < $file ;;
*xz*|*lz*) xz -d < $file ;;
*) cat $file ;;
esac
done
}
But, I'm not always on a machine where I have my rc installed, so I was hoping for a more general solution.