以下のような 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
他の単語の中にない「飛行機」という単語、たとえば「飛行機」を見つけたいので、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をどのように使用すればよいですか?
どうもありがとう。