Многообразный Find word inside special characters or spaces in поля

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.

1
задан 3 January 2016 в 20:53

1 ответ

Можно использовать -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.
2
ответ дан 7 December 2019 в 13:49

Другие вопросы по тегам:

Похожие вопросы: