- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Field seperator help
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
Discussions
Discussions
Discussions
Forums
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
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
тАО04-20-2006 09:42 PM
тАО04-20-2006 09:42 PM
Suppose get below output:
0% ( 0%) 0% ( 0%) Apr 20 19:04 backup
1% ( 0%) 0% ( 0%) Apr 20 19:04 backup
How can I get the field of "Apr" in the script? I try awk , but seems not a good solution as it may go to "20" in some case..Thx.
Bgds,
Gordon
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2006 09:47 PM
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2006 09:51 PM
тАО04-20-2006 09:51 PM
Re: Field seperator help
I suppose u mean $7 :)
OK the thing is, somehow for below output
51% (13%) 0% ( 0%) Apr 20 19:03 backup
$7 will be "20" instead of "Apr", I think the '51' field has some tricky stuff there making it NOT generic to use awk...
Bgds,
Gordon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2006 09:54 PM
тАО04-20-2006 09:54 PM
Re: Field seperator help
the problem is the number of spaces.
If you have a fixed number of spaces
echo "0% ( 0%) 0% ( 0%) Apr 20 19:04 backup" | cut -d' ' -f7
or
If you have a fixed length for each field
echo "0% ( 0%) 0% ( 0%) Apr 20 19:04 backup" | cut -c19-22
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2006 09:54 PM
тАО04-20-2006 09:54 PM
Re: Field seperator help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2006 09:57 PM
тАО04-20-2006 09:57 PM
Re: Field seperator help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-20-2006 10:15 PM
тАО04-20-2006 10:15 PM
Re: Field seperator help
This will extract the field "Apr" (or any three character month) from the format you show:
# perl -nle 'print $1 if /^\d+%.+\)\s+(...)/' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-23-2006 09:53 PM
тАО04-23-2006 09:53 PM
Re: Field seperator help
Another way to use awk is to 'count backward', as it seems the first fields are not always equal in length.
awk '{print $(NF-3)}' test
if your file is called 'test'
Greetings,
Philippe