This what I am trying to get in a bash shell script:
for a in "1" "2 3" "4 5 6"
do
echo "a: $a"
done
a: 1
a: 2 3
a: 4 5 6
But the quotes are treated differently when you use a variable:
echo "\"1\" \"2 3\" \"4 5 6\"" > a.txt
cat a.txt
"1" "2 3" "4 5 6"
read aline < a.txt
If you double-quote the variable, you get this:
for b in "$aline"
do
echo "b: $b"
done
b: "1" "2 3" "4 5 6"
And without quotes you get this:
for b in $aline
do
echo "b: $b"
done
b: "1"
b: "2
b: 3"
b: "4
b: 5
b: 6"
Is there a way to get the for to process the contents of the variable as in the first example?