Wondering what is the right use of here-string (here-document) and pipe.
For example,
a='a,b,c,d'
echo $a | IFS=',' read -ra x
IFS=',' read -ra x <<< $a
Both methods work. Then what would be the difference between the two functionality?
Another problem that I have about "read" is that:
IFS=',' read x1 x2 x3 x4 <<< $a
does not work, x1 is valued as "a b c d", and x2, x3, x4 has no value
but if:
IFS=',' read x1 x2 x3 x4 <<< "$a"
I can get x1=a, x2=b, x3=c, x4=d Everything is okay!
Can anyone explain this?
Thanks in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…