How to tell the "last" command to read from STDIN?

gasko peter
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?

Gilles 'SO- stop being evil'

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)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I tell how much to read from nonblocking stdin?

From Dev

Read from stdin and pipe to next command

From Dev

How to read from stdin in Matlab

From Dev

Why more command cannot read stdin but from piped stdin?

From Dev

how to read ssh output from 'last' and 'who' command

From Dev

SQLite how to read the value of a field from the last ExecuteNonQuery() command

From Dev

How to tell when a user last logged in without using the command last?

From Dev

Use read builtin command to read from parent stdin while in a subshell

From Java

HackerEarth: How to read from STDIN and write to STDOUT?

From Java

How to read from stdin line by line in Node

From Dev

How to make rsync read SRC from STDIN?

From Dev

How to read all lines from stdin in Clojure

From Dev

How to read matrix from stdin in c

From Dev

How to read from stdin with fish shell

From Dev

Perl, how to read from stdin outside a loop?

From Dev

How to read from file *and* stdin in bash

From Dev

How to correctly read a value from stdin into a variable

From Dev

How to read all lines from stdin in Clojure

From Dev

How to read from stdin in process substitution?

From Dev

Perl, how to read from stdin outside a loop?

From Dev

How to read -1 char from stdin?

From Dev

How to read matrix from stdin(console)?

From Dev

How to tell SQLITE to ignore STDIN?

From Dev

tell if last command was empty in PROMPT_COMMAND

From Dev

How can I make `read` read from stdin?

From Dev

Bash read command and stdin redirection

From Dev

Pylint: read from stdin?

From Dev

How to tell if a setInterval is the last thing that's stopping an app from exiting

From Dev

How to read from STDIN in python from a piped grep output

Related Related

HotTag

Archive