Friday, 24 June 2011

how to split a file in linux

If you need to split a single large file into smaller pieces to transfer the files through small memory drives(I had to transfer 4.6 GB matlab ISO using two 4 GB pendrives), there's this simple command line tool called "split" developed by Torbjorn Granlund and Richard M. Stallman.

Fire up the terminal and navigate to the directory in which the file to be splitted is present.

Then, we'll use the split command as below:

split --bytes=2G matlab.iso matlab_

After executing the above command, the iso is divided into smaller chunks of specified file size. The --bytes option can take various different arguments such as 2K, 2M, etc.

To recombine the files into a single file, open the terminal and type the following after navigating to the proper directory.

cat matlab_* > matlab.iso

For more information on the command, type man split.