- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk user name and name from passwd
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2004 10:17 PM
03-23-2004 10:17 PM
I'm trying to produce a list of users from the passwd file. The only info I want to extract is user id and name (fields 1 and 5). I've tried the following:
for i in `cat passwd|awk -F: '{print $1, $5}'`
do
echo $i >> newfile
done
but the user id and name always end up on different lines. I've tried putting \c and "\c" inbetween the $1 and $5 but it has not had any effect.
Any ideas?
Mark Syder (like the drink but spelt different)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2004 10:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2004 10:27 PM
03-23-2004 10:27 PM
Re: awk user name and name from passwd
Will do it
cat /etc/passwd|while read line
do
echo $line|awk -F: '{print $1, $5}' >> newfile
done
Steve STeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2004 10:29 PM
03-23-2004 10:29 PM
Re: awk user name and name from passwd
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2004 10:31 PM
03-23-2004 10:31 PM
Re: awk user name and name from passwd
This thread is now closed as it is working perfectly.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2004 04:49 AM
03-25-2004 04:49 AM
Re: awk user name and name from passwd
I know the thread is closed, but just for
reference, you don't need to use `cat`:
awk -F":" '{print $1,$5}' /etc/passwd
Rob Pierce
--
9 months to Christmas!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2004 04:51 AM
03-25-2004 04:51 AM
Re: awk user name and name from passwd
By any chance do you still believe in Santa?
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2004 05:14 AM
03-25-2004 05:14 AM
Re: awk user name and name from passwd
logins
The formatting is already done for you and there are a plethora of options including the very useful -d to locate duplicate user ID's.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2004 07:21 PM
03-25-2004 07:21 PM
Re: awk user name and name from passwd
Sorry, but asking someone if they still believe in Santa (or Father Christmas as we call him in this country) does not qualify for points!
Bill - logins would have reduced my typing still further, but I tried it twice and it caused a core dump both times.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2004 01:22 AM
03-26-2004 01:22 AM
Re: awk user name and name from passwd
Bill Hassell, sysadmin