Created
July 31, 2013 09:26
-
-
Save coderofsalvation/6120678 to your computer and use it in GitHub Desktop.
Simple way of using csv files as dataformat in bashscripts.
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
# 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