[Linux] Command to split CSV, text files, etc. by specified number of lines
I had a case where I needed to split a CSV file by a certain number of lines, so I used the Linux split command to handle it.
Use the split command to split the file.
split -l 100 users.csv tmp/users-
Use a for loop to add .csv to the end of each filename using the mv command.
cd tmp/
for filename in users-*; do mv $filename $filename.csv; done
That’s it.
That’s all from the Gemba.