Split file and having header kept in all generated files

head -n 1 upload_images.csv > header.csv; tail -n +2 upload_images.csv | split --numeric-suffixes=1 --additional-suffix=.csv -l 320 - --filter='sh -c "{ head -n1 header.csv; cat; } > $FILE"'
 split filename.csv --numeric-suffixes=1 --additional-suffix=.csv -l 50

Result: 50 files named as x{number}.csv

Leave a Reply