可以说我有几个文件包含这个:
[srv] $ cat *.file.* | egrep -R -h -A 3 'is up'
interface0/1, is up
0 input errors, 18 CRC, 0 frame, 0 overrun, 0 ignored
0 output errors, 7299 collisions, 0 interface resets
--
interface0/2, is up
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 output errors, 0 collisions, 0 interface resets
--
interface0/5, is up
669 input errors, 192 CRC, 0 frame, 0 overrun, 0 ignored
0 output errors, 4991 collisions, 0 interface resets
--
.
.
n..
interface0/n, is up
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
0 output errors, 0 collisions, 0 interface resets
--
我想打印出计数器值 > 0 并且“已启动”的任何接口,但 interface resets 除外。当我使用 grep 时,我无法确定该行所属的接口:/
是否可以收集符合我标准的行?