LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   compressing a tar file (https://www.linuxquestions.org/questions/linux-newbie-8/compressing-a-tar-file-4175491496/)

jyunker 01-16-2014 08:28 AM

compressing a tar file
 
I have a tar file that is 11.5 GB large. I want to copy it to a DVD disk. Therefore at present it is too large. It is a tar file created with the command;:

tar -cf works Desktop

which put all of the files on the desktop (plus subdirectories). Now I do not think it is compressed, so can I use a command to now compress this tar file? if so what is the command.

I could start over creating gzipped tar files from scratch, but these tar files have been checked and approved by our network so that would make it a much longer process, if I went through thta again.

Any help appreciated. Thanks in advance.


Respectfully,


jyunker

Habitual 01-16-2014 08:40 AM

Code:

man tar
...
-z, --gzip, --ungzip
              filter the archive through gzip

Let us know where you get stuck.

jyunker 01-16-2014 08:46 AM

compressing a tar file followup
 
Okay, what is the difference between zip and gzip? I can use either whiih has the greater compression?

R,

jyunker

schneidz 01-16-2014 08:49 AM

mite depend on data but i think bzip2 has the greater of compression.

szboardstretcher 01-16-2014 08:56 AM

If you have the time, you can use 'J' which is 'xz' that has the most compression of all.

http://pokecraft.first-world.info/wi..._vs_LZ4_vs_LZO

druuna 01-16-2014 09:05 AM

@jyunker:

tar jcf -> use bzip2
tar zcf -> use gzip
tar Zcf -> use zip
tar --xz cf -> use xz

Untar: tar xf

When untarring you do not have to specify the compression that is used, tar is smart enough to figure it out.

Habitual 01-16-2014 09:09 AM

Quote:

Originally Posted by szboardstretcher (Post 5099148)
If you have the time, you can use 'J' which is 'xz' that has the most compression of all.

Thanks for that nugget!

The "if you have time" reference means it takes longer than say my usual "tar -pczf"?

Mr. Alex 01-16-2014 11:26 AM

jyunker, unlikely you are able to compress 11.5 GB to fit into DVD (unless all of that is text). In order to compress your TAR file, use "xz":

Code:

xz file.tar
This will take a lot of time. But instead you might want to consider splitting your tar archive to fit it into three DVDs:

Code:

split -b 4500M file.tar file.tar.
This will split "file.tar" into 4500Mb-parts and name them "file.tar.aa", "file.tar.ab", "file.tar.ac" and so on... Don't forget about period in the very end of the command (it will make extension visible for you). Then, in order to assemble files into source one, `cat` them like this:

Code:

cat file.tar.?? > file.tar

TobiSGD 01-16-2014 12:08 PM

How much you can compress that tar-archive is dependent on its content. If it is mostly text then you will get very good compression rates. If it is images or videos you will likely end with a larger file after compression, since those files usually are already compressed and compressing them again does nothing but adding overhead. But as Mr. Alex already pointed out, splitting the file may be the better option. Also, keep in mind that you can control the level of compression, a xz -9 will use better compression techniques, but will be significantly slower, while a xz -1 will go faster, but result in a larger file.

Mr. Alex 01-16-2014 01:06 PM

By the way, there is a new super fast compression algorithm: http://code.google.com/p/lz4/ .


All times are GMT -5. The time now is 11:02 AM.