我想得到包含关键词的整个段落。
例如,以下是输出"ifconfig -a"
bond0 Link encap:Ethernet HWaddr 00:11:3F:C1:47:98
inet6 addr: fe80::211:3fff:fec1:4798/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:1881856 errors:0 dropped:0 overruns:0 frame:0
TX packets:1059020 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2618747813 (2.4 GiB) TX bytes:182058226 (173.6 MiB)
bond0:oam Link encap:Ethernet HWaddr 00:11:3F:C1:47:98
inet addr:135.2.156.97 Bcast:135.2.156.111 Mask:255.255.255.240
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
bond0:oamA Link encap:Ethernet HWaddr 00:11:3F:C1:47:98
inet addr:135.2.156.103 Bcast:135.2.156.111 Mask:255.255.255.240
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
我想以粗体提取段落。即该段落包含"bond0:oamA"
我知道的关键词如果我使用grep,只有该行
bond0:oamA Link encap:Ethernet HWaddr 00:11:3F:C1:47:98
会得到。但我想提取整个段落包含的关键词。
有没有办法得到这一段?
非常感谢!