Using csplit to divide a large file in smaller files with a determinated name

479 views Asked by At

Having a very large plaint text file, with about 40 million lines, each line with the same length and format, we want to split it, line by line in N files using csplit. For example, if N is 80, the name of the generated files should be:

FILE00000001.txt
FILE00000002.txt
…
FILE00000080.txt

Note that FILE1.txt, FILE2.txt … FILE80.txt is not valid for us. Thanks!

1

There are 1 answers

0
JLLMNCHR On BEST ANSWER

The parameter I was looking for is '-n 8'. Next example splits BIG_FILE.txt into 18 files of 5000 lines each of them:

csplit -f FILE -n 8 /a/b/c/BIG_FILE.txt 5000 {18}