Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

sed script to manipulate the /etc/passwd file

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 11-29-2009   -   Original Discussion by Pauline mugisha
Pauline mugisha's Unix or Linux Image
Pauline mugisha Pauline mugisha is offline
Registered User
 
Join Date: Nov 2009
Last Activity: 9 December 2009, 9:51 AM EST
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Java sed script to manipulate the /etc/passwd file

Hi. Can anybody help me with a script to extract usernames, shell and home_directory from the /etc/passwd file.

I am stuck
Sponsored Links
    #2  
Old Unix and Linux 11-29-2009   -   Original Discussion by Pauline mugisha
methyl's Unix or Linux Image
methyl methyl is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 8 June 2016, 9:58 PM EDT
Posts: 6,402
Thanks: 288
Thanked 676 Times in 645 Posts
To extract the fields in that order:



Code:
cat /etc/passwd|awk -F: '{print $1,$7,$6}'

Sponsored Links
    #3  
Old Unix and Linux 11-29-2009   -   Original Discussion by Pauline mugisha
fpmurphy's Unix or Linux Image
fpmurphy fpmurphy is offline
Registered User
 
Join Date: Dec 2003
Last Activity: 12 June 2016, 11:03 PM EDT
Location: /dev/ph
Posts: 4,996
Thanks: 73
Thanked 476 Times in 438 Posts
You can eliminate the UUOC (for the unfamiliar - Useless Use of Cat)


Code:
awk -F: '{print $1,$7,$6}' /etc/passwd

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to manipulate logfile text rosspaddock Shell Programming and Scripting 11 12-02-2008 09:10 PM
Shell script to manipulate a message count for the same IP @ diff session gobinath Shell Programming and Scripting 1 05-28-2008 03:13 PM
script to update gecos in passwd file jyoung Shell Programming and Scripting 1 03-05-2008 01:45 PM
How do manipulate file path and names siegfried Shell Programming and Scripting 2 09-28-2007 11:20 AM
manipulate csv file to add columns oscarmon Filesystems, Disks and Memory 6 12-11-2006 08:47 AM



All times are GMT -4. The time now is 11:04 AM.