I'm trying to create an array in bash from a file with the following sample format:
data, data, interesting
data, data, more interesting
The way I'm populating the arrays:
read -r -a DATA1 <<< $(cat $FILE | awk -F, '{ print $1 }')
read -r -a DATA2 <<< $(cat $FILE | awk -F, '{ print $2 }')
read -r -a DATA3 <<< $(cat $FILE | awk -F, '{ print $3 }')
When I examine the array DATA3, there are 3 elements:
interesting
more
interesting
I need it to show only 2 elements like:
interesting
more interesting
How can I preserve the white space in field 3 so when I call that element from the array, it appears as "more interesting"? Is there a better way to handle this?