I have a CSV with each row 2 IPs. I want to combine 2 IPs separated by *** and populate in an array. I tried the code below, but I only get the last row.
#!/bin/bash
INPUT="IPPairs.csv"
array=()
while IFS="," read var1 var2 ; do
echo $var1 $var2
pairString="$var1***$var2"
array+=($pairString)
done < $INPUT
echo "${array[@]}"
IPPairs.csvcomma delimited? Consider tossing some double quotes in therearray+=("$pairString")for example. But with straight IP addresses, you should be fine. If there are domain names in there with backslashes you may want to useread -rto avoid mangling