你的意思:grep abc inputfile |grep -v bcd 需要两次grep,我只想用一次,原因是我要找符合条件的下一行,比如inputfile如下 0 abcd 1 unmatch ha ha 2 abcxyz 3 match ha ha 我只想显示含ha的第3行。如果一个grep可以做到过滤出第2行的话,可以用以下命令: grep unknown_pattern -A1 inputfile |grep ha
【在 u*********r 的大作中提到】 : man grep, hint -v : most
u*r
4 楼
can you do -v first? what if line 0 and line 3 are swapped, do you want to show it or not?
【在 s******a 的大作中提到】 : 你的意思:grep abc inputfile |grep -v bcd : 需要两次grep,我只想用一次,原因是我要找符合条件的下一行,比如inputfile如下 : 0 abcd : 1 unmatch ha ha : 2 abcxyz : 3 match ha ha : 我只想显示含ha的第3行。如果一个grep可以做到过滤出第2行的话,可以用以下命令: : grep unknown_pattern -A1 inputfile |grep ha