- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk processing
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
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
тАО01-21-2009 04:07 AM
тАО01-21-2009 04:07 AM
I am having difficutly getting the following format:
vhost3,U9117.570.65C5B91-V4-C23,inndpr2ap1d1,inndpr2_ap1d1
vhost3,U9117.570.65C5B91-V4-C23,inndpr2ro1d1,inndpr2_ro1d1
I am trying to format all data from the following report:
--------------- -------------------------------------------- ------------------
vhost0 U9117.570.65C5B91-V4-C20 0x00000010
VTD wmbpr1ro1d1
Status Available
LUN 0x8100000000000000
Backing device wmbpr1_ro1d1
Physloc
SVSA Physloc Client Partition ID
--------------- -------------------------------------------- ------------------
vhost1 U9117.570.65C5B91-V4-C21 0x00000011
VTD wmbpr2ro1d1
Status Available
LUN 0x8100000000000000
Backing device wmbpr2_ro1d1
Physloc
SVSA Physloc Client Partition ID
--------------- -------------------------------------------- ------------------
vhost2 U9117.570.65C5B91-V4-C22 0x00000012
VTD inndpr1ap1d1
Status Available
LUN 0x8200000000000000
Backing device inndpr1_ap1d1
Physloc
VTD inndpr1ro1d1
Status Available
LUN 0x8100000000000000
Backing device inndpr1_ro1d1
Physloc
SVSA Physloc Client Partition ID
--------------- -------------------------------------------- ------------------
vhost3 U9117.570.65C5B91-V4-C23 0x00000013
VTD inndpr2ap1d1
Status Available
LUN 0x8200000000000000
Backing device inndpr2_ap1d1
Physloc
VTD inndpr2ro1d1
Status Available
LUN 0x8100000000000000
Backing device inndpr2_ro1d1
Physloc
can someone please help?
Thanks
Chris.
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2009 04:34 AM
тАО01-21-2009 04:34 AM
SolutionThe general solution for such problems is to become a 'gatherer'.
Look for stuff (string patterns!) you can recognize and think are stable, and grab bits and pieces only you see somethign which suggests all pieces should have been accumulated.
After printing often you then need to reset the pieces for the next round, but here you want to keep a header piece which does nto come back each time.
The is a sample awk solution. Just a little more than a 1-liner:
------------------------- test.awk --------
BEGIN { OFS = "," }
/^---/ { getline; host=$1; name=$2 }
/^VTD/ { vtd = $2 }
/^Back/{ print host,name,vtd,$3}
-------------------------------------------
use as: # awk -f test.awk test.txt
Notice:
1) The BEGIN clause sets the Output Field Seperator (OFS) as comma for convenience
2) That "vhostX" is probably not stable enough to latch on to. So the script latches on the the recognizable seperators in the begin of the line before, reads a line (getline) and uses the data from teh next line, not the latch line.
Enjoy!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2009 04:48 AM
тАО01-21-2009 04:48 AM
Re: awk processing
ok thanks - I'll have a look at what I can come up with.
Chris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2009 05:47 AM
тАО01-21-2009 05:47 AM
Re: awk processing
I have adapted the code for other information I also require.
Chris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2009 05:51 AM
тАО01-21-2009 05:51 AM
Re: awk processing
>> I'll have a look at what I can come up with
It should already work.
If it does not, then that's probably because the forum ate spaces.
I like using 'anchors' in my search strings, whether they are strictly needed or not, to prevent stray matches and to speed up misses. Here I used "^" to anchor to the begin of line... but that only works as written when there are no leading spaces.
If you have trouble with the solution, then be sure the reply with the EXACT input example in a TXT file, and perhaps a couple exact outputs as desirable.
Cheers,
Hein.