cancel
Showing results for 
Search instead for 
Did you mean: 

Silly easy one

SOLVED
Go to solution
Adam W.
Valued Contributor

Silly easy one

How would I search /etc/passwd and print only the usernames to the screen?
There are two types of people in the world, Marines and those who wish they were.
5 REPLIES
Steven E. Protter
Exalted Contributor
Solution

Re: Silly easy one

Shalom,

cat /etc/passwd | awk -F: '{ print $1 }'

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: Silly easy one

Hi Adam:

One way:

# awk -F: '{print $1}' /etc/passwd

Regards!

...JRF...
Adam W.
Valued Contributor

Re: Silly easy one

Thanks Guys Cheers!
There are two types of people in the world, Marines and those who wish they were.
James R. Ferguson
Acclaimed Contributor

Re: Silly easy one

Hi (again):

Mind you, the 'cat' is a waste of a process!

Regards!

...JRF...
Michael Mike Reaser
Valued Contributor

Re: Silly easy one

cut -f1 -d: /etc/passwd
There's no place like 127.0.0.1

HP-Server-Literate since 1979