我有一个 sample.txt 文件,如下所示:
1.hi _plane_ is
2.hi airplane is
3.hi plane is
4.hi _plane- is
5.hi :plane: is
plane
there is a plane here
我想在其他单词中找到一个单词“plane”,比如“airplane”,所以在 grep 之后,输出将如下所示(只有第 2 行会被过滤掉)
1.hi _plane_ is
3.hi plane is
4.hi _plane- is
5.hi :plane: is
plane
there is a plane here
我试过:
grep -w "plane" sample.txt
grep "\bplane\b\|\Bplane\B" sample.txt
但输出与我的预期不符。实际上我应该如何使用 grep 来获得正确的结果?
非常感谢。