Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Last active December 29, 2015 15:39
Show Gist options
  • Save coderofsalvation/7692456 to your computer and use it in GitHub Desktop.
Save coderofsalvation/7692456 to your computer and use it in GitHub Desktop.
csv bashsnippet which allows outputting only nth column of a csv (Usage: cat my.csv | ./csv column 2
# quickndirty csv column grep function (for easily selecting columns from csv e.g.)
#
# Usage: cat my.csv | csv column 2
#
# csv is a handy database-format, its editable with an texteditor, importable/exportable by
# tech and end-users (mysql/excel/php etc)
#
column(){
cat - | sed 's/,,,/###/g' | sed 's/,,/##/g' | sed 's/,/#/g' | cut -f$1 -d"#" | sed 's/"//g'
}
@coderofsalvation
Copy link
Author

this function should be removed and is superseeded by supercut

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment