Solved

a regular expression

Posted on 2011-03-23
5
440 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.
Suggested Courses

615 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