+4 votes
in Operating Systems by (40.5k points)
Which Linux command should I use to split a large file into smaller files such that each file contains the same number of lines?

1 Answer

+2 votes
by (353k points)
selected by
Best answer

You can use the Linux command split with the option "-l" to split a big file into smaller files by the number of lines/records per output file. "-l" option is for "put NUMBER lines/records per output file".

E.g., If the big file has 1000 records and you want to create five files, you can use the following command:

split -l 200 big_file_name

The above command will create five files: xaa, xab, xac, xad, and xae.

You can find more details about this command by typing "man split" on the terminal.