How to Gzip File Compression in Unix
Can you help me on how to gzip file compression in unix.
Many modern Unix systems, such as Linux, use GNU tar, a version of tar produced by the Free Software Foundation. If your system uses GNU tar, you can easily use gzip (the GNU file compression program) in conjunction with tar to create compressed archives. To do this, enter the following:
tar -cvzf file.tar.gz inputfile1 inputfile2
Here, the z option tells tar to zip the archive as it is created. To unzip such a zipped tar file, simply enter:
tar -xvzf file.tar.gz
Alternatively, if your system does not use GNU tar, but nonetheless does have gzip, you can still create a compressed tar file, via the following command:
tar -cvf - inputfile1 inputfile2 | gzip > file.tar.gz
Note: If gzip isn't available on your system, use the Unix compress command instead. In the example above, replace gzip with compress and change the .gz extension to .Z (the compress command specifically looks for an uppercase Z). You can use other compression programs in this way as well. Just be sure to use the appropriate extension for the compressed file, so you can identify which program to use to decompress the file later.
If you are not using GNU tar, to separate a tar archive that was compressed by gzip, enter:
gunzip -c file.tar.gz | tar -xvf -
Similarly, to separate a tar archive compressed with the Unix compress command, replace gunzip with uncompress .
Lastly, the extensions .tgz and .tar.gz are equivalent; they both signify a tar file zipped with gzip.
Post new comment
2 Steps to Post a New Problem

