Skip to content

Instantly share code, notes, and snippets.

@d0x
Created October 7, 2015 07:20
Show Gist options
  • Select an option

  • Save d0x/b0492d71b0de535337ab to your computer and use it in GitHub Desktop.

Select an option

Save d0x/b0492d71b0de535337ab to your computer and use it in GitHub Desktop.
Read a CSV from Bash
#!/bin/bash
echo "a,b,c" > test.csv
echo "d,e,f" >> test.csv
OIFS=$IFS
IFS=, #notice: this is your field separator
while read var1 var2 var3
do
echo "Var1: '$var1' Var2: '$var2' Var3: '$var3'"
done <test.csv
IFS=$OIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment