Thursday, October 27, 2011

Ubuntu : Splitting big files in smaller parts using Rar and Joining back(solved)

I wanted to send a big ~40MB doc file via email to a friend. but as we know, there is limit on size of attachment which is 2MB-20MB, varies across different email providers.

I tried to compress file using zip, targz, but size changed minutely. So I remembered some of downloads I get in form of multiple rar files and which get into single file on uncompressing.

I was on ubuntu, I knew thing work smoothly on windows with WinRAR but never uses such thing on linux. I always used zip, tar.gz.

After quick search on google,  I got the thing.

Installed rar on ubuntu using;

sudo apt-get install rar

sudo apt-get install unrar ( though unrar is not needed)


To compress file(s) to split rar archive know which directory you want to compress, I used /home as an example

rar a -m5 -v5M -R myarchive /home/

Let me break the above command down

rar - starts the program
a - tells program to add files to the archive
-m5 - determine the compression level (0-store (fast)...3-default...5-maximum(slow))
-v5M - determine the size of each file in split archive, in this example you get files with size 5MB (if you wanted files of 512kB size you would write -v512k)
myarchive - name of the archive you are creating
/home/ - is folder of the files you wish to add to the archive 



This worked pretty well for me. but now reverse part was tricky. I tried unrar x *.rar. it didnt work.


someone suggested on forum to use "e" option, so I did

rar e part1.rar


and this single command, picked up remaining 3 parts. and formed original file in a moment.

same works with

unrar x part1.rar

while



  • unrar x *.rar doesnt  work.  I think first part itself has meta information about other rar parts.




















No comments: