Skip to content

Instantly share code, notes, and snippets.

@azmigueldario
Created July 18, 2023 18:01
Show Gist options
  • Save azmigueldario/8efcc59e76119a55349cb55f785a9eb1 to your computer and use it in GitHub Desktop.
Save azmigueldario/8efcc59e76119a55349cb55f785a9eb1 to your computer and use it in GitHub Desktop.
Split CSV file according to number of lines and keep header
LINES=100
INPUT_FILE='PATH/TO/TEXT/CSV'
tail -n +2 $INPUT_FILE | split -l $LINES - prefix_
for file in prefix_*
do
head -n 1 $INPUT_FILE > 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