Is there any difference between enclosing grep patterns in single and double quotes?
grep "abc" file.txt
and
grep 'abc' file.txt
I’m asking since there’s no way I could test all possible cases on my own, and I don’t want to stumble into a case that I get wrong 🙂
I see a difference if you have special characters :
Ex :
The shell will try to expand the variable
$barbase, this is maybe not what you intended to do.If instead you type
$baris taken literally.Finally, always prefer single quotes by default, it’s stronger.