Using \ b with grep pattern

I learn bash and I have come across regular expressions. There is an exercise in which I need to combine a word, and I tried to use it \b<word>\b, but for some reason it was not matched until I used it \\b<word>\\b. I really tried this out of despair when I could not understand why it \bdid not work.

+4
source share
2 answers

You can use grep \bword\bthat really grep bwordbafter bash parses the backslash.

Use grep '\bword\b'(pay attention to single quotes).

+3
source

grep -w word .

0

Source: https://habr.com/ru/post/1658961/


All Articles