Wednesday, February 1, 2017

How to use gzip and tar together

To compress and tar a directory in one command, use the following syntax:
# tar -czvf mytarfile.tar.gz mydir
which will tar and compress the directory "mydir" with its contents.

To extract and untar a .tar.gz file in one command, use the following syntax:
# tar -zxvf mytarfile.tar.gz
To extract and untar a .tar.gz file in one command, into a specific directory, use the following syntax:
# tar -zxvf mytarfile.tar.gz -C /data1/mydir

No comments:

Post a Comment