In a bash script, how do I split a large text/csv file into n files (each of m rows); the resulting file names need to be numbered starting from 1 and increment by 1 [0,1…999…].
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
csplitcommand is pretty much made for this job:That will split
input.csvinto 100-line files for the first 200,000 lines in the file. The output files will beginoutput-csv.and will be followed by 4 digits. The-kmeans ‘do not clean up on receipt of a signal’. Adjust numbers according to size of input file and your whims and desires.Note the quirky behaviour of the first file, documented at the POSIX manual page linked to.