Solved

parsing 'last' or 'utmp' output?

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

679 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