string - bash word splitting mechanism -


i new bash , seeing there automatic word splitting done bash:

a="1  2     3 4" 

if echo "a" echo $a got 1 2 3 4, has done word splitting implicitly. if loop through "a", got 1, 2, 3, , 4 respectively.

i read here that

the shell scans results of parameter expansion, command substitution, , arithmetic expansion did not occur within double quotes word splitting.

and found if have

b=$a; echo "$b" 

i

"1 2 3 4" 

so, here problem: when word splitting done? change string itself? take effect when use echo or for (loop)? more general, how bash handle on earth?

great thanks!!

read man bash. assignment, says

all values undergo tilde expansion, parameter , variable expansion, command substitution, arithmetic expansion, , quote removal [ ... ] word splitting not performed, exception of "$@" explained below under special parameters. pathname expansion not performed.

word splitting not happen in [[ ]] conditions:

word splitting , pathname expansion not performed on words between [[ , ]]


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -