I am trying to create an array from bash from a file with the following sample:
data, data, interesting
data, data, more interesting
Array Fill Method:
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 DATA3 array, there are 3 elements:
interesting
more
interesting
I need it to display only two elements:
interesting
more interesting
How can I save a space in field 3, so when I call this element from an array, it looks like "more interesting"? Is there a better way to handle this?
source
share