Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Shell one-liner to: Get the first row of a bunch of CSV files (ostensibly headers) and write them all to the same file, but with the first element of that file being the name of the file without `csv`
$ for file in *.csv; do echo "${file%.csv},$(head -n 1 $file)" >> headers; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment