Em grep
, \<
significa início da palavra e \>
significa fim da palavra .
De man grep
:
The Backslash Character and Special Expressions
The symbols \< and \> respectively match the empty string at the
beginning and end of a word. The symbol \b matches the empty string at
the edge of a word, and \B matches the empty string provided it's not
at the edge of a word. The symbol \w is a synonym for [_[:alnum:]] and
\W is a synonym for [^_[:alnum:]].
Portanto, grep '\<hi\>'
corresponderá a qualquer linha que contenha a palavra hi
e grep 'hi'
corresponderá a qualquer linha que contenha a sequência de caracteres hi
:
$ grep '\<hi\>' <<< "hi"
hi
$ grep '\<hi\>' <<< "chimes"
$ # no output since no match
$ grep '\<hi\>' <<< "hi-fi"
hi-fi
$ grep '\<hi\>' <<< "high voltage"
$ # no output since no match