- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: awk help - printing fields in a record
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
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
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-21-2013 06:54 AM
03-21-2013 06:54 AM
awk help - printing fields in a record
Good afternoon
I am attempting to print certain fields from a file using awk but really am struggling with the output ....
I execute a home grown script
pclroute -c sl_hosts "lsvg rootvg"
the output is:
[sl37]
VOLUME GROUP: rootvg VG IDENTIFIER: 00c8d37e00004c00000001378f20f6fe
VG STATE: active PP SIZE: 32 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 1022 (32704 megabytes)
MAX LVs: 256 FREE PPs: 155 (4960 megabytes)
LVs: 20 USED PPs: 867 (27744 megabytes)
OPEN LVs: 19 QUORUM: 2 (Enabled)
TOTAL PVs: 2 VG DESCRIPTORS: 3
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 2 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 256 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable
PV RESTRICTION: none INFINITE RETRY: no
[sl39]
VOLUME GROUP: rootvg VG IDENTIFIER: 00c8d37e00004c0000000129f5b5f02c
VG STATE: active PP SIZE: 32 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 1022 (32704 megabytes)
MAX LVs: 256 FREE PPs: 516 (16512 megabytes)
LVs: 17 USED PPs: 506 (16192 megabytes)
OPEN LVs: 16 QUORUM: 2 (Enabled)
TOTAL PVs: 2 VG DESCRIPTORS: 3
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 2 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 256 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable
PV RESTRICTION: none INFINITE RETRY: no
[sl41]
VOLUME GROUP: rootvg VG IDENTIFIER: 00c8d37e00004c00000001125668753e
VG STATE: active PP SIZE: 32 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 1022 (32704 megabytes)
MAX LVs: 256 FREE PPs: 454 (14528 megabytes)
LVs: 18 USED PPs: 568 (18176 megabytes)
OPEN LVs: 17 QUORUM: 2 (Enabled)
TOTAL PVs: 2 VG DESCRIPTORS: 3
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 2 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 256 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable
PV RESTRICTION: none INFINITE RETRY: no
so I execute the same script with the following awk syntax but it doesnt quite work as I expect it too:
pclroute -c sl_hosts lsvg rootvg |awk 'BEGIN{H=0;PP=0;TP=0}
/^\[/ { H = $0}
/PP SIZE/ { PP = $6 }
/TOTAL PP/ { TP = $6 }
{print H,PP,TP}'
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl37] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl39] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
[sl41] 32 1022
as always any help or suggestions would be greatly appreciated
thanks
Chris
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2013 07:12 AM
03-21-2013 07:12 AM
Re: awk help - printing fields in a record
hmmmm maybe if I remembered help I got in the past I'd be able to do this ....
I have searched my notes and previous posts and found this:
pclroute -c sl_hosts lsvg rootvg |awk '/^\[/ {if (line != "") print line; line =$NF} /PP SIZE/{line=line ":" $6} /TOTAL PP/ {line=line ":" $6} END {print line}'
[sl37]:32:1022
[sl39]:32:1022
[sl41]:32:1022
open to other suggestions though :)
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2013 08:11 AM
03-21-2013 08:11 AM
Re: awk help - printing fields in a record
This should work too ;)
pclroute -c sl_hosts lsvg rootvg | awk '/^\[/ {printf "%s ", $0} /PP SIZE/ {printf "%s ", $6}; /TOTAL PP/
{printf "%s\n", $6}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2013 09:14 PM
03-21-2013 09:14 PM
Re: awk help - printing fields in a record
>This should work too
Probably better to accumulate the data in a variable then output all at once (and format it like a program ;-):
pclroute -c sl_hosts lsvg rootvg | awk '
/^\[/ {
line = $0
}
/PP SIZE/ {
line = line ":" $6
}
/TOTAL PP/ {
print line ":" $6
}'
Of course bad things will happen if there isn't that [x], PP SIZE and TOTAL PP sequence.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2013 04:12 AM
04-02-2013 04:12 AM
Re: awk help - printing fields in a record
thank you gents
Chris