I wanted to find $featuredicon
variable in my php files, and I ran grep -ir "$featuredicon"
I understood that dollar sign is reserved character in shell. But what does it actually do? Did I modify my php files? I'm afraid I did something bad…
next time I will run grep -ir "\$featuredicon"
Best Answer
The reason why every single line of every single file was listed was due to variable substitution of your shell.
When you call
bash
will evaluate that. It will look up the variable$featuredicon
and put it into your command. Guess what$featuredicon
most likely is?Right, nothing. So what you're actually doing is:
And that matches every line of every file.
Old Answer
The dollar sign (
$
) is a placeholder forend-of-line
in regular expression (I assume the same is true for grep).If you want to search for a dollar sign, use
'\$'
.Be sure to check the StackOverflow question: How to grep for the dollar symbol ($)?