I have a 2-field csv file with the following values:
subID,Task
A,BLOCK
B,BLOCK
C,Finger
Reading via a read-while loop, if I print the two fields in order...
while IFS=',' read -r -a vars ; do
echo ${vars[0]} ${vars[1]}
done < some.csv
A BLOCK
B BLOCK
C Finger
But if I reverse the print order...
while IFS=',' read -r -a vars ; do
echo ${vars[1]} ${vars[0]}
done < some.csv
A
B
C
In fact, any text before ${vars[1]} will be ignored:
while IFS=',' read -r -a vars ; do
echo foo bar ${vars[1]} ${vars[0]} foo bar
done < some.csv
A foo bar
B foo bar
C foo bar
Just what is going on? Is BLOCK some sort of control character in bash?