I am learning to script in Bash.
I have a CSV file with 5 columns and 22 rows. I am interested in taking the data from the second column and put it into an array.
What I want is that the first name be in array[0], the second in array[1] and so on.
Bash script:
#!/bin/sh
IFS=","
eCollection=( $(cut -d ',' -f2 MyAssignment.csv ) )
printf "%s\n" "${eCollection[0]}"
The CSV looks like this. There is no line with headers.
The column with the 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
The bash script is not placing the 2nd column into the array, what am I doing wrong?