- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how do I write a shell program
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-25-2000 08:56 AM
09-25-2000 08:56 AM
how do I write a shell program
2. a program to display a sorted list of the logged in users. Just the user name and no other information.
Your help will be greatly appreciated!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2000 09:00 AM
09-25-2000 09:00 AM
Re: how do I write a shell program
Try this:
# ls | wc -l
# who | sort | more
..JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2000 09:03 AM
09-25-2000 09:03 AM
Re: how do I write a shell program
Oh, sorry, you only wanted the username, so:
# users
...or if you prefer more fancy...
# who|sort|awk '{print $1}'
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2000 09:24 AM
09-25-2000 09:24 AM
Re: how do I write a shell program
ls -a | wc -l
or if you want a recursive method
find . | wc -l
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2000 10:49 AM
09-25-2000 10:49 AM
Re: how do I write a shell program
cd $HOME (users home directory)
find . -depth | wc -l
Users logged in:
who | awk '{print $1}' | sort | uniq -c
This will list all users who are logged in but if you only want to see the user names once, this is providing the unique feature. If a username appears more than once in the output, the 'uniq -c' will eliminate the duplicates and show the name once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2000 09:45 PM
09-25-2000 09:45 PM
Re: how do I write a shell program
who | awk '{print $1}' | sort -u
This saves you one command and will be a little bit faster.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2000 01:33 AM
09-26-2000 01:33 AM
Re: how do I write a shell program
If you are searching all the files in a user directory you should use the find command because it recuyrsively discends the directory hierarchy for the path you fornish:.
You could use this form:
find user_dir -type f | awk '{print "TOTAL FILES => " NR }'
and about the users logged in :
who | awk '{print $1}'| sort -u
federico