Tuesday, March 18, 2008

tar and gzip/bzip on a single command on AIX

This command will be helpful when you do not have an option "z" for tar. In Linux you can directly specify "z" option in tar command but in AIX, you can not ....

To compress:

"tar cvf - abc | gzip > abc.tar.gz"

"tar cvf - abc | bzip2 > abc.tar.bz2"

To uncompress:

"gunzip < abc.tar.gz | tar xvf -"

"bzip2 < abc.tar.bz2 | tar xvf -"


5 comments:

Anonymous said...

To uncompress, it should be bunzip2

"bunzip2 < abc.tar.bz2 | tar xvf -"

Anonymous said...

thanks
satish

Anonymous said...

Thanks....i never worked on AIX and now i'm in serious of this command..

Rahul Raut said...

Thanks!
Great help!

Anonymous said...

For various compression ratios using:

tar cvf - file1 file2 ... fileN | gzip -(1-9) > abc.tar.gz