Shell Grep Regular Expression – Escaping * with Regular Expressions and Grep

grepquotingregular expressionshell

I have a file that has unique lines that start with 2 stars (**).

However when I run a grep command for

grep \*\* fileName 

I get all of the lines in the file. This is very unusual, and what I see as non-matching lines do not contain **.

How would I escape the ** for the correct lines to be found?

Best Answer

So try :

egrep "^\*\*" YOUR_FILE

Don't forget to use double quote.

Note: Use egrep instead of grep.
If you want to use grep use grep -E

Related Question