Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a large file (8GB for Example). How can I split it into multiple parts, let's say 3 equal parts, and after that how do I integrate them later?

share|improve this question
    
This seems to be a duplicate of askubuntu.com/questions/12172/… –  Jo-Erlend Schinstad Jul 27 '11 at 2:25
    
Are you sure "This seems to be"?. Heck, it is the same exact thing. Except here is now with a bonus of "More examples and alternatives." –  Luis Alvarado Jul 27 '11 at 2:40
    
It might help if you say more about why you want to split it, and whether you want it split just into byte substrings or whether you're open to having them wrapped up in any kind of error checking or labelling. If this is to put it on smaller media or for network transfers I'd look at something like par2. –  poolie Jul 29 '11 at 3:07
add comment

6 Answers 6

up vote 67 down vote accepted

There are several ways to accomplish this. Let's start with the basic ones.

Using the split and cat commands:

Lets says I have an image and its too big (10MB). All I do is:

split --bytes=1M /path/to/image/image.jpg /path/to/image/prefixForNewImagePieces

and then to put it together I use cat:

cat prefixFiles* > newimage.jpg

For example:

Assuming am inside the folder where the image is:

split --bytes=1M myimage.jpg new

if the image is inside a directory called images you can also do this:

split --bytes=1M images/myimage.jpg new

If the image is inside the directory /home/cyrex/images you can do this:

split --bytes=1M /home/cyrex/images/myimage.jpg new

(In all the cases above it will split myimage.jpg in 1MB pieces and prefix the name of the pieces with the word new. So they would look like newaa, newab, newac, newad...)

If you are splitting a Text file and want to split it by lines you can do this:

split -l 1000 book.txt new

Which will split the text file in output files of 1000 lines each. This is another way to split a file and is mostly used for text files like logs, sql dumps, csv files, etc..

Then I merge them

cat new* > newimage.jpg

This is one way. You can even change the size of the splitted pieces. Just change the part that says --bytes=1M to --bytes=1K for 1 kilobyte or 1G for giga, or another number like --bytes=4K for 4KB pieces.

Using Nautilus

Another way is the compress option in the gui of Nautilus. It gives you an option to split the file or files you want to compress into smaller megabyte sizes. Its simple and easy.

Yet another way is using 7z

Assuming you have an ISO image called ubuntu.iso you could do this:

7z a -v5m -mx0 ubuntu.7z ubuntu.iso

This will create 5MB size files from the ubuntu.iso. The -v5m is the volume size so you can change it to 10, 12, 1, 3 and also the m can be changed to k for kilobytes, etc; the -mx0 switch tells 7-Zip to use no compression, that is, just to split data into parts.

To extract just do

7z x ubuntu.7z.001

this way you extract the first file and 7z starts extracting from the following files in order. You can also do

7z e ubuntu.7z.001

which has the same effect here.

share|improve this answer
1  
Did not include rar since is not open source yet (As far as I know) and did not add Tar since I was looking for easy ways of doing the split. –  Luis Alvarado Jul 26 '11 at 15:14
    
Add gzip as well - 7zip requires a package install iirc –  Broam Jul 27 '11 at 1:19
    
For what i know, Gzip (like tar) do not have an easy option to split the compressed file. In all cases i have seen them using the split command to "split" the compress file. So it would not be a command but a group of commands to achieve a single purpose which can be done with a single one like split or 7z. For the installation of 7Zip (which is the p7zip of p7zip-full package) it has never asked me for iirc ;). –  Luis Alvarado Jul 27 '11 at 2:39
    
Added splitting of text files. Forgot about that and today it just so happened I needed to split a couple of CSV files. This is for those dumps that you need to be of a specific amount of lines. –  Luis Alvarado Sep 9 '11 at 22:47
add comment

Using split -b with the approrpiate number, you can get three pieces.

Number could be

size=$(wc -c <"file name")
one_third=$((size/3+1))

To reassemble, use cat

cat "file name"* > "file name"

Manuale pages will help to fill the details.

share|improve this answer
add comment

Gnome split? http://gnome-split.org/

GNOME Split is a tool that allows you to split files and merge them back. It is written in Java and uses a GTK+ user interface (thanks to the java-gnome project). The goal is to offer a native implementation of similar projects which can handle multiple file formats (e.g. Xtremsplit).

http://www.omgubuntu.co.uk/2010/08/split-large-files-easily-in-ubuntu-with-gnome-split/

share|improve this answer
add comment

HOZ - Hacha Open Zource v1.65 - http://hoz.sourceforge.net/

enter image description here

From the developer:

OZ is what you would call a 'file splitter'. Its file format is the same as the one used by the 'Hacha' software, a well known splitter in Spain and Latinamerica. HOZ is an open-source and portable C implementation of an 'Hacha' compatible splitter.

HOZ is smaller and faster than 'Hacha'.

btw, I used a 'Z' isntead of a 'S' in 'Zource' because 'hoz' is 'sickle' in spanish, and since 'hacha' is the spanish word for 'axe'...

After installing, you can use the Hoz GUI by dropping ghoz in a terminal. The operation is so simple that needs no explanation but further information can be reached in the developer's site.

Good luck!

share|improve this answer
add comment

HJSplit

Is a popular freeware program to split and recombine files. The program is available on Windows, Linux and a variety of other platforms.

HJSplit for Linux is a freeware file splitter for Linux with full graphical user-interface. HJSplit supports file sizes of over 100 Gigabytes, Split, Join/Recombine, MD5 checksums, file-compare, "run without install" and the program is fully portable.

HJSplit for Linux does not need to be installed and it does not depend on any special libraries. Just extract the hjsplitlx.tar.gz archive into a directory of your choice and start the program from the Linux file manager or a terminal window. You might need to adjust the program's file permissions to 'executable'.

enter image description here

share|improve this answer
1  
Must i say that the Windows file does works on Linux too. –  Uri Herrera Jul 26 '11 at 14:54
1  
There are several ways of splitting/joining a file before having to go to a program like this. I rather use the powerful options that linux offers and for splitting/merging files it has some pretty fast, safe ways of doing it. –  Luis Alvarado Jul 26 '11 at 15:12
1  
It is safe, fast, AND is cross-platform that includes LINUX, it's not a WINDOWS-only application that just happens to run In Linux too... –  Uri Herrera Jul 26 '11 at 15:26
1  
I use HJSplit, it's great and simple. No need to type out commands and parameter names when you can just fill the parameter values into text boxes. –  Matthew Read Jul 26 '11 at 18:14
    
This isn't Free Software, it's only a free download. I'd rather a solution be in the package repositories and FAIF. –  Broam Sep 11 '11 at 15:15
show 1 more comment

WoodCutter

A free file split and merge utility developed in Java. It is a small size application that allows a user to split any type of file in smaller sizes in KB, MB or GB.

It is available for Linux as well as Windows.

WoodCutter offers 3 ways of merging back the original files. WoodCutter creates a merge file which can be processed by the WoodCutter application to join all the files back. In case the receiver of split files does not have WoodCutter installed, then also the original file can be obtained as WoodCutter also creates a batch file and a Shell script file to merge the files back. The batch file will be used in Windows platform and Shell script will be used in Linux platforms.

http://java-puzzle.blogspot.com/2009/07/woodcutter.html

share|improve this answer
1  
The license is "freeware." I think a Free Software tool that's in the repos is a better solution. –  Broam Sep 11 '11 at 15:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.