Skip to content

Instantly share code, notes, and snippets.

@arjenblokzijl
Created August 13, 2015 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arjenblokzijl/871094c9c4cae716d4de to your computer and use it in GitHub Desktop.
Save arjenblokzijl/871094c9c4cae716d4de to your computer and use it in GitHub Desktop.
Split CSV file and preserve header
tail -n +2 file.txt | split -l 4 - split_
for file in split_*
do
head -n 1 file.txt > tmp_file
cat $file >> tmp_file
mv -f tmp_file $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment