Вопрос

If I have a file named test with 1 line of text: \<.abc

and do a grep '\<abc' test

why do I get a result?

How can I fix this?

Это было полезно?

Решение

In general when working with regular expressions if you want to match a literal backslash character it needs to be escaped, so you should see the correct behavior if you use grep '\\<abc' test.

As for what the \< is actually doing in the regular expression, this is from the grep man page:

   The symbols \< and \>  respectively  match  the  empty  string  at  the
   beginning and end of a word.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top