I am going crazy to understand why the following bash code:
#! /bin/bash
myarrx=($(cat /Users/Porcac/Downloads/2.csv))
for ((i=0;i<${#myarrx[@]};++i)); do
echo ${myarrx[i]} | while IFS=, read -r number alphabet animal colour behaviourCode behaviour
do
echo "number='$number' alphabet='$alphabet' animal='$animal' colour='$colour' behaviourCode='$behaviourCode' behaviour='$behaviour'"
done
done
Prints the string like the one in the screenshot
As you can see, the part of the string that comes after the last array item, is then printed at the beginning of the line and is overriding the initial part of the string. I really don't understand why it doesn't accept other strings after the last array item. The array is taking the content from a .cvs file that looks like this:
Any suggestion?
The array DOES NOT contain any special character, only simple words