You can also do it using -v
(for --invert-match
) option of grep as:
(你也可以使用grep的-v
(for --invert-match
)选项来--invert-match
:)
grep -v "unwanted_word" file | grep XXXXXXXX
grep -v "unwanted_word" file
will filter the lines that have the unwanted_word
and grep XXXXXXXX
will list only lines with pattern XXXXXXXX
.
(grep -v "unwanted_word" file
将过滤具有unwanted_word
的行,而grep XXXXXXXX
将仅列出模式为XXXXXXXX
。)
EDIT:
(编辑:)
From your comment it looks like you want to list all lines without the unwanted_word
.
(从您的评论看起来您想要列出没有unwanted_word
所有行。)
In that case all you need is: (在这种情况下,您只需要:)
grep -v 'unwanted_word' file
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…