Operating System - HP-UX
1820798 Members
3864 Online
109628 Solutions
New Discussion юеВ

Re: Pipe or redirect "tar" to "gzip"

 
D'Urso Joe
Occasional Contributor

Pipe or redirect "tar" to "gzip"

I've seen it done & and I have even done it myself in the past but I can't
figure it out again -

What is the correct syntax to pipe or redirect tar to gzip ? (What I'm trying
to do is compress the tar file as I add files to it)

Please e-mail me suggestions
3 REPLIES 3
Neil Gast_1
Frequent Advisor

Re: Pipe or redirect "tar" to "gzip"

The following should work:

tar cvf - fileglob | gzip > myzippedfile.gz

Obviously, replace "fileglob" with whatever makes sense.

Be careful with block size with this command. I've seen tar do some odd things.
In fact, you should probably use this format, just to be safe:

tar cvbf 20 - fileglob | gzip > myzippedfile.gz

As a side note, there are versions of tar available that will both tar and
compress at the same time. I can't remember where to get that version, but it's
probably a gnu tool.

MrNeil
Neil Gast_1
Frequent Advisor

Re: Pipe or redirect "tar" to "gzip"

I forgot to mention... If you name your gzipped output file has a .tgz
extension, gunzip is smart enough to know that it's a gzipped tar file, and
will rename it with a .tar extension when gunzipped later.

MrNeil
Francisco Soler
Occasional Contributor

Re: Pipe or redirect "tar" to "gzip"

See http://hpux.csc.liv.ac.uk/hppd/hpux/Gnu/tar-1.13.14/ there ara a new tar
command that compress and uncompress directly with the "-z" option.

Frank.