I am currently working with a bash script. I have a csv file where every line looks like the following:
1,ABC DEF
2,GHI JKL
I want to create an array with only values in the second field, and then print them.
My current solution is the following:
myarr=($(awk -F, '{print $2}' filename.csv))
for i in "${myarr[@]}"
do
echo $i
done
My output looks like this:
ABC
DEF
GHI
JKL
When I need it to look like this:
ABC DEF
GHI JKL
I need the result to be in a variable for future operations!
How do I solve this problem?