Csv files are very underrated. Below is a pretty straightforward way to read in a csv file in bash. Regardless of it’s simplicity, I thought I’d share it. I may need to remind myself later how to do this.
#!/bin/bash
INPUT=data.csv
OLDIFS=$IFS
IFS=, # the delimiter of your csv file, using a comma here
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read col1 col2
do
echo "col1: $col1"
echo "col2: $col2"
done < $INPUT
IFS=$OLDIFS