Created
October 7, 2015 07:20
-
-
Save d0x/b0492d71b0de535337ab to your computer and use it in GitHub Desktop.
Read a CSV from Bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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