Solved

parsing 'last' or 'utmp' output?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
CPU monthly average? 12 92
LastLogonTimeStamp Attribute 7 47
MarkLogic 1 51
How to clone solaris 10 machine 33 76
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

743 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

9 Experts available now in Live!

Get 1:1 Help Now