hi all,
could any one tell me what is diffrence in using " " and ' ' in grep.
eg what is diff in the following
grep "ram" filename
grep 'ram' filename
hi all,
could any one tell me what is diffrence in using " " and ' ' in grep.
eg what is diff in the following
grep "ram" filename
grep 'ram' filename
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
This will simply display the string $var as it is, no variable replacement by value.
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 !!