- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- About the 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
01-02-2005 05:48 PM
01-02-2005 05:48 PM
#who -u |grep testuser
testuser pts/17 Jan 1 13:55 00:50 16525 (168.0.7.1)
testuser pts/16 Jan 1 09:25 00:15 20834 (198.0.7.2)
#who -u |grep testuser |awk '{ print $7 }
16525
20834
If I only want to get the result of "16525" ( get the line 1 only ) , what can I do ? thx
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2005 06:14 PM
01-02-2005 06:14 PM
Re: About the shell script
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2005 06:16 PM
01-02-2005 06:16 PM
Re: About the shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2005 06:29 PM
01-02-2005 06:29 PM
Re: About the shell script
Trond's reply is probably more efficient than my previous reply.
Another way to do this is:
#who -u |grep testuser |awk '{ print $7 } | read -r a; echo $a
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2005 06:33 PM
01-02-2005 06:33 PM
Re: About the shell script
#who -u |grep testuser | read -r a b c d e f g h;echo $g
:-)
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2005 07:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2005 08:34 PM
01-02-2005 08:34 PM
Re: About the shell script
who -u|grep ^testuser|awk '{print $7}'|head -1
BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2005 08:54 PM
01-02-2005 08:54 PM
Re: About the shell script
who -u |grep testuser |awk '{print $7;exit}'
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2005 09:15 PM
01-02-2005 09:15 PM
Re: About the shell script
Perhaps the most correct solution if you want to use awk
who -u |grep testuser |awk 'BEGIN {getline; print $7 }'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2005 01:06 AM
01-03-2005 01:06 AM
Re: About the shell script
who -u | perl -ane 'if (m/testuser/) {print "$F[6]\n"}' | head -1
I'm sure perl has a internal "head" type function but I'm not 100% sure!!
Tim