1828346 Members
3300 Online
109976 Solutions
New Discussion

help in a script

 
Kwhite_1
Advisor

help in a script

Hello,

I have a file that consists of abput 1000 records as shown below for example.

VG Name /dev/vgswap
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 2
Open LV 2
Max PV 16
Cur PV 1
Act PV 1
Max PE per PV 25000
VGDA 2
PE Size (Mbytes) 4
Total PE 12860
Alloc PE 12500
Free PE 360
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0


Now the question is I need to write a report by grasping two strings from the above on the same line like


Max PE per PV 25000 VGDA 2
3 REPLIES 3
VK2COT
Honored Contributor

Re: help in a script

Hello,

One of many possibilities with awk(1):

awk 'BEGIN { ORS=" " } /^Max PE per PV|^VGDA/ {print}'

Cheers,

VK2COT
VK2COT - Dusan Baljevic
James R. Ferguson
Acclaimed Contributor

Re: help in a script

Hi:

# vgdisplay|awk '/^VG Name/ {X=$NF};/^Max PE per PV/ {X=X" "$0};/^VGDA/ {print X" "$0}'

Regards!

...JRF...
Tingli
Esteemed Contributor

Re: help in a script

vgdisplay | egrep "Max PE per PV|VGDA" | sed -n '/Max/{N;s/\n//;p;}'