- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script needed here
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
09-05-2003 09:44 AM
09-05-2003 09:44 AM
- Filter to list all logins that have default directory starting with /home/*
- Show only two columns, the userID, and Real Name.
- The order must be Real Name, a comma (,) and userID.
So, far I have
cat /etc/passwd | grep /home>>file1
cat file1 | cut -f 1,5 -d:>file2
rm file1
After this, I am not sure how to invert the order of the columns, so it will be real name first and then userID
Any help appreciated. With points of course!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2003 09:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2003 09:57 AM
09-05-2003 09:57 AM
Re: Script needed here
cat /etc/passwd | grep /home>>file1
cat file1 | cut -f 1,5 -d:>file2
rm file1
My approach would be to modify the script I'm attaching to put your columns out with awk.
You can use awk to print certain columns any way you want.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2003 10:00 AM
09-05-2003 10:00 AM
Re: Script needed here
something like
awk -F: '$6 ~ "/home" {
printf "%s,%s\n",$5,$3
}' /etc/passwd > newfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2003 10:02 AM
09-05-2003 10:02 AM
Re: Script needed here
grep /home /etc/passwd | cut -d: -f 1,5 | awk -F':' '{ print $2 "," $1 }'
Consider to print qoutes around $2, in case the real name follows the convention
"Name , Location, Phone"
which will give your "comma" a bad standing to be a good delimiter.
Hope this helps
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2003 10:05 AM
09-05-2003 10:05 AM
Re: Script needed here
#!/bin/ksh
IFS=:
while read aa bb cc dd ee ff gg
do
[[ $ff = /home/* ]] && echo "$ee,$aa"
done < /etc/passwd > file3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2003 10:08 AM
09-05-2003 10:08 AM
Re: Script needed here
Have to say I think Vitak beats my awk mangling :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2003 10:23 AM
09-05-2003 10:23 AM
Re: Script needed here
I'll bet, scripting-questions are the ones that get the fastest solutions all over the forum.
Guess because nearly everybody has to do with it, so the number of forumers who can provide a bit of knowledge is a whole lot broader than those able to tell something about a specific raid-controller.
And of course: solving puzzles is always fun.
Have fun
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2003 10:30 AM
09-05-2003 10:30 AM
Re: Script needed here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2003 11:53 AM
09-05-2003 11:53 AM
Re: Script needed here
I've tried them all, and they all work for the same results. After reviewing them all, I will have to give points to everyone.
Vitek, very good script! I am really pleased with it.
Volker your script is swift. Just one line, I will use your script after reviewing it with my staff (unanimous decision). Please reply for additional bonus points.
Thanks everyone who responded for the scripts, suggestions, and help.
E.