Splitting files into a new folder Splitting files into a new folder shell shell

Splitting files into a new folder


Try this:

split -l 20000 helloworld.txt output/x

Reference: http://linux.die.net/man/1/split


@Rob has the answer, and here's a small script using it that tries to defend against BASH's deficiencies as a programming language:

#!/bin/bash# make BASH fail on errors and unset variablesset -euoutput='output_dir'file_to_split="helloworld.txt"# make the directory# -p means no errors if the directory is there alreadymkdir -p "${output}"split -l 20000 "${file_to_split}" "${output}/${file_to_split}."