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
03-15-2011 09:42 PM
03-15-2011 09:42 PM
sql statement returned 2 columns and i like to get the result of a second column " RUNNING" using awk '{print $2}'
but because of space between the words. the result was not correct.
Please give some suggestions on how to use "awk" or "cut" to get the result which is the
"RUNNING"
Thanks in advance.
Workflow Deferred Agent Listener RUNNING
Workflow Deferred Notification Agent Listener RUNNING
Workflow Error Agent Listener RUNNING
Workflow Inbound JMS Agent Listener RUNNING
Workflow Inbound Notifications Agent Listener RUNNING
Workflow Java Deferred Agent Listener RUNNING
Workflow Java Error Agent Listener RUNNING
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2011 12:06 AM
03-16-2011 12:06 AM
SolutionYou are going to have to provide more details of how the fields are defined. Unless you always want the last column?
You can use awk to print the last column, $NF. And work backward, $(NF-1).
Otherwise you may have to use advanced AI technology to determine where your fields begin and end.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2011 12:17 AM
03-16-2011 12:17 AM
Re: Awk help
I've noticed that in all lines always appear "Agent Listener " before "RUNNING", so you can use it as field limiter. eg:
#cat sample.txt
Workflow Deferred Agent Listener RUNNING
Workflow Deferred Notification Agent Listener RUNNING
Workflow Error Agent Listener RUNNING
Workflow Inbound JMS Agent Listener RUNNING
Workflow Inbound Notifications Agent Listener RUNNING
Workflow Java Deferred Agent Listener RUNNING
Workflow Java Error Agent Listener RUNNING
#cat sample.txt |awk -F"Agent Listener " '{ print $2 }'
RUNNING
RUNNING
RUNNING
RUNNING
RUNNING
RUNNING
RUNNING
I hope it will be useful.
Rgds.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2011 03:29 AM
03-16-2011 03:29 AM
Re: Awk help
awk '{print $NF}' /tmp/mysql.out
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2011 03:52 AM
03-16-2011 03:52 AM
Re: Awk help
You can try this,
# awk '{for (i=0;i<=NF;++i) if ($i ~ "RUNNING") print $0 }' file
It will print all the line contains RUNNING .
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2011 08:37 AM
03-16-2011 08:37 AM
Re: Awk help
Thank you all for your helps.
Regards,