SERVER:~ # zcat /var/log/wtmp-20130827.gz | last -f -
last: -: No such file or directory

Without uncompressing the wtmp file, how can I see the output of if it with the last command?


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.

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)

No way.

last(1) is not designed to be able to read stdin. Either /var/log/wtmp or -f xxx

It doesn't support '-'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.