shell - What is the difference between "$a" and $a in unix -
this question has answer here:
- when wrap quotes around shell variable? 3 answers
for example:
#!/bin/sh a=0 while [ "$a" -lt 10 ] b="$a" while [ "$b" -ge 0 ] echo -n "$b " b=`expr $b - 1` done echo a=`expr $a + 1` done*
the above mentioned script gives answer in triangle while out double quotes, falls 1 after other on diff lines.
after variable expanded value, word splitting (i.e. separating value tokens @ whitespace) , filename wildcard expansion takes place unless variable inside double quotes.
example:
var='foo bar' echo no quotes: $var echo quotes: "$var"
will output:
no quotes: foo bar quotes: foo bar
Comments
Post a Comment