Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save edmondscommerce/87472f274e47ed90a2dafa2cdf48a75f to your computer and use it in GitHub Desktop.

Select an option

Save edmondscommerce/87472f274e47ed90a2dafa2cdf48a75f to your computer and use it in GitHub Desktop.
Get Column Numbers for CSV file in Bash
# This will take a CSV file as input,
# pull out the header row,
# split that onto new lines
# and then prepend a zero indexed line number to each line
head ./filename.csv -n 1 | sed "s/,/\n/g" | awk '{printf("%d %s\n", NR-1, $0)}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment