Skip to content

Instantly share code, notes, and snippets.

@kalinchernev
Created April 25, 2018 14:26
Show Gist options
  • Save kalinchernev/464cfbdfdfd30549efbaa3d369946d58 to your computer and use it in GitHub Desktop.
Save kalinchernev/464cfbdfdfd30549efbaa3d369946d58 to your computer and use it in GitHub Desktop.
split csv file into several files by a given number of items, head row is preserved
#!/bin/sh
tail -n +2 activity.csv | split -l 8000 - split_
for file in split_*
do
head -n 1 activity.csv > tmp_file
cat $file >> tmp_file
mv -f tmp_file "$file.csv"
rm $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment