shell - What is the difference between "$a" and $a in unix -


this question has answer here:

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

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -