Solved

a regular expression

Posted on 2011-03-23
5
436 Views
Last Modified: 2012-05-11
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
Comment
Question by:zhshqzyc
  • 2
  • 2
5 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 25 total points
ID: 35199946

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

wmp
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 35199968
.. or just

grep "bash" /etc/passwd  | cut -f1,7 -d:
0
 
LVL 4

Expert Comment

by:roemelboemel
ID: 35200051
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
 
LVL 4

Assisted Solution

by:roemelboemel
roemelboemel earned 25 total points
ID: 35200077
missed the passwd file
awk -F: ' $7~/\/bash$/{ print $1":"$7 } '  /etc/passwd

Open in new window

0
 

Author Comment

by:zhshqzyc
ID: 35200307
awk -F: ' $7~/\/bash$/{ print $1":"$7 } '

Open in new window

It is not working but thanks for your input.

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

15 Experts available now in Live!

Get 1:1 Help Now