Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 446
  • Last Modified:

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.
0
zhshqzyc
Asked:
zhshqzyc
  • 2
  • 2
2 Solutions
 
woolmilkporcCommented:

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
 
roemelboemelCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now