I am participating in a script in Bash.
I have a CSV file with 5 columns and 22 lines. I am interested in taking data from the second column and putting it in an array.
I want the first name to be in array[0]
, the second to array[1]
, etc.
Bash script:
#!/bin/sh IFS="," eCollection=( $(cut -d ',' -f2 MyAssignment.csv ) ) printf "%s\n" "${eCollection[0]}"
CSV is as follows. No title bar.
The column with Vl18xx
numbers is what I want to split into an array.
John,Vl1805,VRFname,10.9.48.64/28,10.9.48.78 John,Vl1806,VRFname,10.9.48.80/28,10.9.48.94 John,Vl1807,VRFname,10.9.48.96/28,10.9.48.110 John,Vl1808,VRFname,10.9.48.112/28,10.9.48.126 John,Vl1809,VRFname,167.107.152.32/28,167.107.152.46
bash script doesn't put 2nd column in array, what am I doing wrong?