- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Change 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
11-07-2007 01:29 PM
11-07-2007 01:29 PM
$me=$(whoami)
$awk -F: -v me=$me '$1==me {print $2}' /tmp/test.txt
$2
The current test.txt is as below:
$vi test.txt
user1:1
user2:2
user3:3
now , if the test.txt is changed the format as below , can advise how to change my script to check the user no.
$vi /tmp/test.txt
user1 - 1
user2 - 2
user3 - 3
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2007 01:49 PM
11-07-2007 01:49 PM
Solutiondo you have the space between the user and the number ?
-- if no space then replace the -F: with -F- and it should work , so the full line will be
awk -F- -v me=$me '$1 == me { print $2}' /tmp/test1.txt
otherwise try this -- if you want the space
awk -v me=$me '$1==me {print $3}' /tmp/test.txt
Regards,
RD
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2007 02:02 PM
11-07-2007 02:02 PM
Re: Change script
It works .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2007 05:42 PM
11-07-2007 05:42 PM
Re: Change script
the script works fine ,
awk -v me=$me '$1==me {print $3}' /tmp/test.txt
but I found if the test.txt have # sign as below , then there is no output , can advise how to change the script ? thx
$vi /tmp/test.txt
#user1 - 1
#user2 - 2
#user3 - 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2007 09:54 PM
11-07-2007 09:54 PM
Re: Change script
I fixed it , please ignore the previous messages.