- 论坛徽章:
- 145
|
回复 1# clockbj
for your reference
$ awk -f vg_info.awk vg.txt | column -t
VOLUME-GROUP: VG-IDENTIFIER: VG-STATE: PP-SIZE: VG-PERMISSION: TOTAL-PPs: MAX-LVs: FREE-PPs: LVs: USED-PPs: OPEN-LVs: QUORUM: TOTAL-PVs: VG-DESCRIPTORS: STALE-PVs: STALE-PPs: ACTIVE-PVs: AUTO-ON: MAX-PPs-per-VG: MAX-PPs-per-PV: MAX-PVs: LTG-size: AUTO-SYNC: HOT-SPARE: BB-POLICY:
ldapvg 00c6616f00004c00000001057eef41cd active 256-megabyte(s) read/write 3119-(798464-megabytes) 256 11-(2816-megabytes) 37 3108-(795648-megabytes) 20 11-(Enabled) 21 21 0 0 21 no 32512 1016 32 128-kilobyte(s) no no relocatable
spdbvg 005da87f00004c00000000fb0b22b6e9 active 512-megabyte(s) read/write 407-(208384-megabytes) 256 49-(25088-megabytes) 49 358-(183296-megabytes) 46 2 1 2 0 0 1 no 1016 32 128-kilobyte(s) no no
$ cat vg_info.awk
function ind(s){
return(index($0,s))
}
function trim(s){
gsub("^[ \t]+|[ \t]+$","",s);
gsub(" +","-",s);
#sub(":$","",s)
return(s)
}
function g(s,e,str){
if(e=="")
return(trim(substr(str,s)))
return(trim(substr(str,s,e-s-1)))
}
/VOLUME GROUP/{
if(++H==2) print h
if(H>1)print d
p[1]=1;
p[2]=ind($3);
p[3]=ind($4);
p[4]=ind($6);
h=d=""
}
{
s=$0;
for(n=1;n<=4;++n){
$n=g(p[n],p[n+1],s);
}
NF=4
#print;
h=h $1" "$3" "
d=d $2" "$4" "
}
END{
print d
}
|
|