- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scripting 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
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
10-29-2007 07:15 PM
10-29-2007 07:15 PM
I have a file which has some 10 coloumns. If the value of the 6th field is non zero value then i need to print out first field
STWBK01 2979 WNT FTA 40 0
USTWNA01 2979 WNT FTA 40 0
USTWA448 2979 WNT FTA 40 HI
Now i want the output as
USTWA448
As the 6th field here is not 0 but HI.
what awk combination shall i use to get this?
thanks in advance
George
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2007 07:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2007 01:59 AM
10-31-2007 01:59 AM
Re: Scripting help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2007 02:47 AM
10-31-2007 02:47 AM
Re: Scripting help
Hmmm, thanks for playing, but that's just so wrong on so many levels!
1) Why bring our attention back to a problem with a perfect solution?
2) Why pipe through grep when awk is perfectly happy to read the file directly and pretty much designed to do the filtering. ( awk '/HI/{print $1}' FILENAME )
but most importantly...
3) this 'solution' will have false positives for records where other columns happen to have the character sequence HI in them
4) this 'solution' will have false negatives for cases where column 6 is not 0, but not HI either.
The question/requirement was
"If the value of the 6th field is non zero"
Cheers!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2007 06:11 AM
10-31-2007 06:11 AM
Re: Scripting help
Hein, there is a shorter solution:
awk '$6+0 {print $1}' file
and yes, no forced conversion to integer is needed, even this will work:
awk '$6 {print $1}' file
The evaluation of $6 to TRUE will exactly succeed when the condition of Geoerge is met.
mfG Peter