How to find all matches of exact word in поля inside directory (including subdirectories) which май be surrounded by special characters or spaces or nothing (beginning or end of line). I think this is common when searching in source code.
Многообразный Let's say inside the поля I want to find word is
. It should find these occurences:
is
(this is the only word in в line)
(is)
"is"
this is something
For example grep -r in
does find matches inside other words which I don't need.
Можно использовать -w
или --word-regexp
флаг, например,
grep -wr 'is' .
От man grep
-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.