答案1
像这样的输入——
Physical Disk : 'IBM (67)
device=/dev/mapper/1234
shareddisk=true
Physical Disk : 'IBM (68)
device=/dev/mapper/6789
shareddisk=true
以下 awk 脚本输出 --
awk -v RS="" 'BEGIN{print "Phys disk Device shareddisk"} {j=0; for (i=0; i<3; i++) {print substr($(4+j),2) ,$(5+j), $(6+j), $(7+j); j+=7} }' input
Phys disk Device shareddisk
IBM (67) device=/dev/mapper/1234 shareddisk=true
IBM (68) device=/dev/mapper/6789 shareddisk=true