Enclose the $ in square brackets [ .. ], that is, specify the special character as a character class. For example,
grep ‘[$]foo’ file.txt
Enclose the $ in square brackets [ .. ], that is, specify the special character as a character class. For example,
grep ‘[$]foo’ file.txt
Nope, \d has no meaning (unless using -P for PCRE). You need [[:digit:]] instead; i.e.,
grep 'foo[[:digit:]]*'
Pipe the output of grep through grep -v. For example:
grep 'A' file | grep -v 'B'
The bar | has no special meaning in BRE (basic regular expressions). Use extended regular expressions (ERE) such as:
grep -E 'foo|bar' file
or
egrep 'foo|bar' file
In GNU grep, you can also force the spcial meaning of | by escaping it. E.g.,
grep 'foo\|bar' file
grep originated from ed command: g/re/p where re is a regular expression, g stands for globally, and p stands for print. So one could say grep is an acronym of “Global Regular Expression Print“.