HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- passwd script frustration
Operating System - HP-UX
1826414
Members
4142
Online
109692
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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-11-2008 08:36 AM
09-11-2008 08:36 AM
Ok, I'm trying to get information about disabled users on my system. I wrote a simple for loop but, it is not working the way I want it to.
#> for a in `cat listOfUsers `;do
>grep $a /etc/passwd | awk -F: '{print $1 ":" $6}' >> Info.txt
>done
But, all I get is the information on the last person in the list. What am I doing wrong?
#> for a in `cat listOfUsers `;do
>grep $a /etc/passwd | awk -F: '{print $1 ":" $6}' >> Info.txt
>done
But, all I get is the information on the last person in the list. What am I doing wrong?
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2008 08:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2008 08:58 AM
09-11-2008 08:58 AM
Re: passwd script frustration
Hi Stephanie:
What does your file, 'ListOfUsers' look like? If it has one user (name) per line, this should work.
That said, you can eliminate *two* extra processes! --- a 'cat' and a 'grep'. Let the shell read and split the fields. Let 'awk' match what you need and print it.
#/usr/sin/sh
while read NAME X; do
awk -v NAME=${NAME} -F: '$1==NAME {print $1 ":" $6}' /etc/passwd
done < listOfUsers > info.txt
exit 0
Regards!
...JRF...
What does your file, 'ListOfUsers' look like? If it has one user (name) per line, this should work.
That said, you can eliminate *two* extra processes! --- a 'cat' and a 'grep'. Let the shell read and split the fields. Let 'awk' match what you need and print it.
#/usr/sin/sh
while read NAME X; do
awk -v NAME=${NAME} -F: '$1==NAME {print $1 ":" $6}' /etc/passwd
done < listOfUsers > info.txt
exit 0
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2008 09:50 AM
09-11-2008 09:50 AM
Re: passwd script frustration
Both are wonderful suggestions. But, my problem was that I ftp'd the file over from windows and it had the ^M at the end of every line. :) I hadn't noticed because I was using "more" instead of "vi" on the file.
It's always those little things that get you.
Thanks for your help!
It's always those little things that get you.
Thanks for your help!
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP