Solved

parsing 'last' or 'utmp' output?

Posted on 1997-01-18
1
425 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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 144
How to find files recursively in ftp server quickly? 7 99
check unix curl command return value 7 82
unix solaris snoop command 6 83
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now