When you are managing a massive Linux database server, you frequently need to transfer massive, 50-Gigabyte log files to a secure backup server across a slow network connection. Attempting to copy a single 50GB file is incredibly risky; if the network connection drops at 99%, the entire transfer fails, and you must start over from the very beginning. To guarantee network stability, you must mathematically shatter the massive file into hundreds of tiny, easily manageable chunks using the split command.
How the split Command Works
The split command does not compress or alter the underlying binary data. It acts like a digital guillotine, physically slicing a single massive file into multiple smaller, identically sized pieces. Once the tiny pieces are safely transferred to the destination server, you simply use the cat command to instantly glue them back together into the original file.
To shatter a file, you must declare exactly how you want the slices measured (usually by byte size or by line count), followed by the name of the target file.
To slice a massive database_dump.sql file into strict, 500-Megabyte chunks, use the -b (bytes) flag:
split -b 500M database_dump.sql
The command executes silently. When you run the ls command, you will discover that the original massive file remains perfectly intact, but the directory is now filled with dozens of new files named xaa, xab, xac, xad, etc. Every single one of these new files is exactly 500 Megabytes in size (except the final file, which contains the leftover remainder).
Splitting by Line Count
If you are processing a massive, 10-million line CSV data file, slicing it strictly by Megabytes is incredibly dangerous because the guillotine might slice directly through the middle of a word, destroying a row of data. When dealing with raw text files, you must always split by line count to preserve data integrity.
To shatter the CSV file into chunks of exactly 100,000 lines each, use the -l (lines) flag:
split -l 100000 customer_data.csv
This guarantees that every single newly created file contains exactly 100,000 perfectly intact, uncorrupted rows of data.
Restoring the Shattered File
Once you have successfully uploaded all the tiny xaa, xab, xac files to the new backup server, you must reassemble them.
Because the split command deliberately names the chunks in perfect alphabetical order, you can simply use the cat command with a wildcard to mathematically merge them back into a single, cohesive file:
cat x* > restored_database_dump.sql
The Linux kernel will instantly stitch the binary fragments together in absolute alphabetical order, resulting in a perfect, 1-to-1 clone of the original massive file.