- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- Languages and Scripting
- >
- Re: awk help - printing fields in a record
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
- Email to a Friend
- 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
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP