Posted October 5, 2009 by Spyros in Linux Tips

How to Split Large Files in Linux/Unix


Have you ever been in the position where you needed to transfer a very big file to another computer but had to split that in more pieces so that you can actually copy it ? This would have definately happened to you if you use a FAT32 formatted disk drive that doesn’t allow for files larger than 4GBs. So, what happens if you want to transfer a file that is 8GBs ?

The Unix Split Command

Luckily, the GNU tools are there to save us. There is a unix tool called split that can be used for such a process. Let’s suppose(for the sake of simplicity) that we want to split a 10KB file to smaller pieces. We use this command to split the file to chunks of 2kb and thus we get 5 new files.

thought@thought:~/Desktop/pieces$ split -b 2k /home/thought/Desktop/example /home/thought/Desktop/pieces/example

This command will split the file named example to 5 smaller pieces and then put these pieces to the folder /home/though/Desktop/pieces/ under the prefix “example”. Therefore, we will be getting 5 new files named like:

exampleaa exampleab  exampleac examplead exampleae

In order to reunite these files back to one single file, after we copy them, we execute the command :

thought@thought:~/Desktop/pieces$ cat examplea* > merged

This will merge all our files to the standard output of the shell and forward it to a new file named merged.

Hope this was helpful for you !