Skip to content

Instantly share code, notes, and snippets.

@stardigits
Created November 20, 2018 20:07
Show Gist options
  • Save stardigits/02360e7168d0d7ba5a3be3b63258407b to your computer and use it in GitHub Desktop.
Save stardigits/02360e7168d0d7ba5a3be3b63258407b to your computer and use it in GitHub Desktop.
Transpose CSV string header with line number in Bash
# Example:
# echo "one,two,three,four,five" | csv_header
# Result:
# 1 one
# 2 two
# 3 three
# 4 four
# 5 five
csv_header () { head -1 | tr , \\n | cat -n; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment