hofbrau hofbrau - 1 year ago 119
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

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

Answer Source

You need to escape the + sign:

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

The unescaped dot . already matches every character

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download