grepコマンドを使用すると、他の単語の一部でもその単語がすべて選択されます。たとえば、grepを使って「the」という単語を見つけると、「theatre」の「the」も強調表示されます。
部分単語ではなく完全な単語のみを選択するようにgrepコマンドを調整する方法はありますか?
ベストアンサー1
-w, --word-regexp
Select only those lines containing matches that form whole
words. The test is that the matching substring must either be
at the beginning of the line, or preceded by a non-word
constituent character. Similarly, it must be either at the end
of the line or followed by a non-word constituent character.
Word-constituent characters are letters, digits, and the
underscore.
~からman grep