tar packing and unpacking

Overview: .tar.gz format is first packaged into .tar format and then compressed into .gz format; .tar.bz2 format is first packaged into .tar format and then compressed into .bz2 format.

.tar.gz format packaging and decompression method
1. Pack and compress 3 texts to /tmp/ under
tar -zcvf /tmp/test.txt.tar.gz 1.txt 2.txt 3.txt
Parameter description:
-z - -gzip, compress and decompress archives by gzip
-c --create, create a new archive, pack
-v --verbose, show the printing process
-f --file, specify the packed archive file name
1.txt 2.txt 3 .txt multi-file package compression

2. Extract the .tar.gz format package to /opt/ under
tar -zxvf test.txt.tar.gz -C /opt/
Parameter description:
-x --extract, extract the file from the archive
-C Change the directory to the specified Location


3. View the compressed package file tar -ztvf test.txt.tar.gz
parameter description without decompression :
-t List archive contents

.tar.bz2 format packaging and decompression method
1. Pack and compress 3 texts to /tmp/ under
tar -jcvf /tmp/test.txt.tar.bz2 1.txt 2.txt 3.txt
Parameter description:
-j - -bzip2, compress and decompress archives via bzip2

2. Extract the .tar.bz2 format package to /opt/ under
tar -jxvf test.txt.tar.bz2 -C /opt/


3. View the compressed package file tar -jtvf test.txt.tar.bz2 without decompression

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324971514&siteId=291194637