- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: /etc/passwrd
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-12-2001 06:55 AM
12-12-2001 06:55 AM
/etc/passwrd
My thinking is to lock in on the "::" on each line were the password would go.
Any ideas..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:01 AM
12-12-2001 07:01 AM
Re: /etc/passwrd
I am not sure if this is the easiest way, but you could do
while eline;do
pass=`echo $eline | awk -F: '{ print $2 }'`
if [ ! -z "$pass" ]; then
echo $eline >> tmpfile
fi
done< /etc/passwd
mv tmpfile /etc/passwd
...BPK...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:03 AM
12-12-2001 07:03 AM
Re: /etc/passwrd
Try this:
# awk -F: '$2 ~/\*/ {print}' /etc/passwd
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:05 AM
12-12-2001 07:05 AM
Re: /etc/passwrd
--
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:06 AM
12-12-2001 07:06 AM
Re: /etc/passwrd
OK (sorry), for truly enpty fields, do this:
# awk -F: '$2 ~/^$/ {print}' /etc/passwd
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:06 AM
12-12-2001 07:06 AM
Re: /etc/passwrd
An awk one-liner should do the trick:
cat /etc/passwd | awk 'BEGIN { FS = ":" } { if (length($2) < 1) print $0 }'
That should do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:08 AM
12-12-2001 07:08 AM
Re: /etc/passwrd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:12 AM
12-12-2001 07:12 AM
Re: /etc/passwrd
I'd do it the same way as James but without wishing to be pedantic, if you want to strip out those lines with a NULL password field and keep the other lines you need only lines where $2 is not NULL, ie
awk -F: '$2 !~ /^$/ {print}' /etc/passwd > newpasswd_file
Simon.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:14 AM
12-12-2001 07:14 AM
Re: /etc/passwrd
On a tangent, if the system is a trusted system, the passwords will be under the /tcb directory structure. The password field in the /etc/passwd file with be just * .
HTH
raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:17 AM
12-12-2001 07:17 AM
Re: /etc/passwrd
awk -F : '$2 ~/^$/ {print $0}' /etc/passwd
To replace all the fields that look like ::
sed 's/::/:*:/' /etc/passwd > pass
mv pass /etc/passwd
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:28 AM
12-12-2001 07:28 AM
Re: /etc/passwrd
awk -F: '$2 !~/^[A-z]/ && $2 !~/^[0-9]/ { print } ' /etc/passwd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2001 07:31 AM
12-12-2001 07:31 AM
Re: /etc/passwrd
If you have perl, this will do an in-line edit, and store a backup automatically in /etc/passwd.orig:
perl -naF: -i.orig -e 'print $_ unless ($F[1] eq "")' /etc/passwd
Rgds, Robin.