SERVER:~ # zcat /var/log/wtmp-20130827.gz | last -f - last: -: No such file or directory SERVER:~ #
Without uncompressing the wtmp file, how can I see the output of if it with the last command?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
last doesn't support reading from a pipe. You can use
/dev/stdin as a file name, but that's kind of useless since it only works if you're redirecting from a file in the first place.
Uncompress the file to a temporary file.
wtmp=$(mktemp) zcat /var/log/wtmp-20130827.gz >|"$wtmp" last -f "$wtmp" rm -f "$wtmp"
Zsh has a form of process substitution
=(…) which puts the output of a command in a temporary file.
last -f =(zcat /var/log/wtmp-20130827.gz)