Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

parsing 'last' or 'utmp' output?

Posted on 1997-01-18
1
Medium Priority
?
435 Views
Last Modified: 2013-12-16
I need to be able to extract information in fields produced by commands like 'last'(hostname, dates, etc) and other listings that use a variable number of spaces to align columns. I can't use 'cut' as I would when extracting stuff from /etc/passwd - the delimiter arg doesn't work when applied to the ouput from 'last'.
0
Comment
Question by:eciad-unix
1 Comment
 

Accepted Solution

by:
spank earned 200 total points
ID: 1811870
 Use awk.  e.g.

last | awk '{print $1}'

will give you a list of usernames.

last | awk '{print $3}'

will give you a list of hostnames.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question