LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-10-2011, 03:02 AM   #1
rohitbhpune
LQ Newbie
 
Registered: Oct 2011
Location: Pune,India
Distribution: RHEl 6
Posts: 2

Rep: Reputation: Disabled
select only user who use /bin/bash shell from the /etc/passwd folder


Hi,

How can I select only user who use /bin/bash shell from the /etc/passwd folder and copy them in another file?
 
Old 10-10-2011, 03:11 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
You can try sed or awk:
Code:
$ sed -n '\:/bin/bash$:p' /etc/passwd
$ awk -F: '$NF == "/bin/bash"' /etc/passwd
 
Old 10-10-2011, 03:14 AM   #3
rohitbhpune
LQ Newbie
 
Registered: Oct 2011
Location: Pune,India
Distribution: RHEl 6
Posts: 2

Original Poster
Rep: Reputation: Disabled
awasome..works perfect...tanks a lot..
 
Old 10-11-2011, 09:21 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960
What's wrong with a simple grep?
Code:
grep '/bin/bash' /etc/passwd
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux authentication with LDAP - select user's shell based on group membership slinx Linux - Software 4 08-02-2011 07:50 PM
[SOLVED] Randomly select a folder using Shell Scripting kapz_unlocked Linux - Newbie 7 06-21-2011 12:02 AM
[SOLVED] Shell script for printing user from /etc/passwd sandeep_hello Linux - General 3 10-15-2010 08:14 AM
/bin/bash shell for apache pridefc Linux - Security 4 03-16-2008 03:55 PM
Scripts failing with #!/bin/bash or other shell on first line rdfoerster Fedora 6 11-16-2004 07:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration