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
05-31-2007 07:01 AM
05-31-2007 07:01 AM
Please I need a help with the awk command.
When I run the command:
:#/ls -al prof* | head -1 |awk '{print $9}'
I have the following:
prof.u18
How can I get only "u18" in the same line command?
Please, could someone give me a help?
Thanks,
clefeitosa
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2007 07:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2007 07:11 AM
05-31-2007 07:11 AM
Re: awk
# ls -al prof* | head -1 | awk '{split($9,a,".");print a[2]}'
...although you can eliminate the 'head' process too:
# ls -al prof* | awk '{NR==1 && split($9,a,".");print a[2]}'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2007 07:16 AM
05-31-2007 07:16 AM
Re: awk
...and since it's the last field of the 'ls' output you want:
# # ls -al prof* | awk '{NR==1 && split($NF,a,".");print a[2]}'
...that is, why count nine fields when $NF points to the last...
Thus is you "slip" and do 'ls -als' and there are ten fields, everything still works!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2007 07:26 AM
05-31-2007 07:26 AM
Re: awk
Thanks for all answer.
Was very useful
I'm using the following:
ls -al prof* | head -1 | awk -F "." '{print $2}'
Thanks a lot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2007 07:27 AM
05-31-2007 07:27 AM
Re: awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2007 03:38 PM
05-31-2007 03:38 PM
Re: awk
$ ls -a prof*
Then you only need to process the one field and don't have to count. :-)