by mbb70 · 3y ago · 0 comments
`head -n1 /path/to/file.csv | tr ',' '\n' | nl | grep desired_column`
gives you the column number of desired_column
$ printf 'one\n\nthree\n' | nl
1 one
2 three
Set -ba to enable numbering all lines.For this use case I usually end up running cat -n instead since I find it easier to remember.
edit: I like your 'nl' better as it is using white space instead of colon as a separator.