hofbrau hofbrau - 5 months ago 21
Linux Question

grep “+” operator does not work

File content (text.txt)

test aNd###liKe test


Example 1, working

grep -i "and...like" test.txt


Example 2, not working

grep -i "and.+like" test.txt


Operator
+
just needs at least one match or more, but why is example 2 not working?

Answer

You need to escape the + sign:

grep -i "and.\+like" test.txt

The unescaped dot . already matches every character