a regular expression

I want a scipt to display a list of all the users on your system who log in the Bash shell as a default.(Linux Fedora 14)
I guess grep is helpful  but not sure.

Thanks.
zhshqzycAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
woolmilkporcConnect With a Mentor Commented:

awk -F: '{if($NF~"bash") print $1, $NF}' /etc/passwd

wmp
0
 
woolmilkporcCommented:
.. or just

grep "bash" /etc/passwd  | cut -f1,7 -d:
0
 
roemelboemelCommented:
I would do it with awk as with a simple grep you would als catch a user called "bash" or when you have email addresss in the gecos field and your company has the domain "i-love-bash.org" as email domain...
awk -F: ' $7~/\/bash$/{ print $1":"$7 } ' 

Open in new window

0
 
roemelboemelConnect With a Mentor Commented:
missed the passwd file
awk -F: ' $7~/\/bash$/{ print $1":"$7 } '  /etc/passwd

Open in new window

0
 
zhshqzycAuthor Commented:
awk -F: ' $7~/\/bash$/{ print $1":"$7 } '

Open in new window

It is not working but thanks for your input.

0
All Courses

From novice to tech pro — start learning today.