Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created July 31, 2013 09:26
Show Gist options
  • Save coderofsalvation/6120678 to your computer and use it in GitHub Desktop.
Save coderofsalvation/6120678 to your computer and use it in GitHub Desktop.
Simple way of using csv files as dataformat in bashscripts.
# example usage: cat foo.csv | while read line; do getCSVColumn "$line" 2; done
getCSVColumn(){
echo "$1" | sed 's/,,,/###/g' | sed 's/,,/##/g' | sed 's/,/#/g' | cut -f$2 -d"#" | sed 's/"//g'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment