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 - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -