Quote:
Originally Posted by
vino
You will not find any difference between those two grep's. Rather try these two and see the difference.
grep '$USER' /etc/passwd
grep "$USER" /etc/passwd
Open the man pages of sh or ksh and see the section on Quoting. Basically single quotes prevent variable expansion.
Adding to Vino's comment...
variables in single quotes are treated as const. string
as
1. var = 5 ;
echo '$var'
This will simply display the string $var as it is, no variable replacement by value.
2. var = 5;
echo "$var"
In double quotes variables get expansion in terms of its value.
o/p will be 5
Similarly is the case with grep '$var' and grep "$var".
But when it comes to constant string, it hardly reflects any change.
grep -w "string1 string2" file1
grep -w 'string1 string2" file1
Both are same.
Hope you get this !!