- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: USER LOGIN NAME SHELL SCRIPT
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-20-2000 07:54 AM
09-20-2000 07:54 AM
I am trying to write a shell script to find out, for example, how many users have a login name with less than 4 characters and then those that have 4 or more characters.
Thanks for any/all help.
Andy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2000 08:27 AM
09-20-2000 08:27 AM
Solutioncreate a file from the lines below and call it as shown
#!/usr/bin/awk
#
# Awk file to count number of users in /etc/passwd that have
# less than 4 char user names and those with 4 or more
#
# invoke with awk -f countusers /etc/passwd
BEGIN { FS = ":" ; lessthan = 0 ; morethan = 0 }
{
if ( length ($1) < 4 )
lessthan++
else
morethan++
}
END { print "number of users with less than 4 characters " lessthan " \n";
print "number of users with more 4 or more chars " morethan ; }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2000 08:43 AM
09-20-2000 08:43 AM
Re: USER LOGIN NAME SHELL SCRIPT
If, for instance, you want this based on the active user count, try this:
# who|awk '{if (length($1)>=4) LSS4++; else GTR4++}; END {print "LSS=">LSS,"GTR="GTR}'
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2000 08:46 AM
09-20-2000 08:46 AM
Re: USER LOGIN NAME SHELL SCRIPT
Oops:
# who|awk '{if (length($1)>=4) LSS4++; else GTR4++}; END {print "LSS="LSS4,"GTR="GTR4}'
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2000 08:53 AM
09-20-2000 08:53 AM
Re: USER LOGIN NAME SHELL SCRIPT
grep -v [-+] /etc/passwd| awk -F: '{if (length($1)>=4) LSS4++; else GTR4++};END{
print "LSS="LSS4,"GTR="GTR4}'