- 论坛徽章:
- 4
|
回复 7# blackold
多谢各位
多谢黑哥来指导
但当Link detected行之后,Setting行之前还有其他行时
如- Settings for eth0:
- ......
- ......
- Link detected: yes
- aaaaaa
- 123456
- ******
- Settings for eth0:
- ........
- ........
复制代码- sed -n '/Setting/{:a;N;/Link/!ba;/detected:.*yes/!p}' urfile
- sed '/Link detected:/{/Link detected: *yes$/!{H;g;p;d}};/^Settings/{h;d};H;d' urfile
复制代码 上面的代码还可是有效的,但下面的就不行了- awk -v RS='Settings' -F: 'NR>1{if($NF!~/yes/) {print t$0}}{t=RT}' urfile
复制代码 再请教一下,对于另一种情况,如果条件行在中间
如,如果LV Status 不为available,把此逻辑卷内容全部打印,基中末尾行Block device的值不是确定的- --- Logical volume ---
- LV Path /dev/VolGroup/lv_swap
- LV Name lv_swap
- VG Name VolGroup
- LV UUID QHTZSc-Jt58-D7mb-sOG5-YaEd-A6sY-5IByzV
- LV Write Access read/write
- LV Creation host, time localhost.localdomain, 2014-07-12 19:05:57 +0800
- LV Status available
- # open 1
- LV Size 2.42 GiB
- Current LE 620
- Segments 1
- Allocation inherit
- Read ahead sectors auto
- - currently set to 256
- Block device 253:1
复制代码 |
|