How to read a csv file in bash

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.

IFS=,   # the delimiter of your csv file, using a comma here
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read col1 col2
        echo "col1: $col1"
        echo "col2: $col2"
done < $INPUT
post by Kelt Dockins on 03/26/2012