- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Grep command
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
12-10-2002 08:05 AM
12-10-2002 08:05 AM
We are planning to move some 50 users from one system to the other. I have a list user IDs for those 50 users. I am planning to create user accounts for them on the new machine by taking the /etc/passwd entries from the old machine. Now how do I grep the /etc/passwd file so that the user id is matched only with the first word of the passwd file (ie. the user ID field). Because when I do the follwoing,
for i in `cat 50users`
do
grep -w $i /etc/passwd >> /tmp/50passwdentries
done
The user id which is present in the comment field of passwd file is also taken in to consideration so that I am ending up with having duplicate entries. Pl. help.
Thanks in advance
Karthik
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2002 08:12 AM
12-10-2002 08:12 AM
Re: Grep command
grep -w ^$i /etc/passwd
will search at the start of the password file only. You could further delimiter it with;
grep -w ^$i: /etc/passwd
so that it only finds the exact userid up until the first :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2002 08:24 AM
12-10-2002 08:24 AM
Re: Grep command
with grep ^$i: it is able to get only 5 or 6 users. What could be the problem??
Thanks
Karthik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2002 08:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2002 08:30 AM
12-10-2002 08:30 AM
Re: Grep command
Did you remove your /tmp/50passwdentries file before you run your for loop each time ?
You will have to provide a list of your 50users and the passwd file in order to diagnose it further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2002 09:03 AM
12-10-2002 09:03 AM
Re: Grep command
Thank you carlos.
grep -w -f solved my problem.
Stefan: grep -w works with 11i :-). Thanks for your help too.
Karthik