Article Directory
tar command
Tar currently supports compressing and decompressing compressed files in .tar.gz, .tar.xz, .tar.bz2 format . Of course, .tar files are also supported , that is, without adding any compression and decompression algorithm parameters. But tar does not support .zip, .rar and other formats, please use zip, unzip, rar and other commands to achieve.
parameter
It is enough to know the most commonly used parameters. If you need to use other manuals
Required parameters:
1. -f
Use archive files or equipment, usually required
Specify compression and decompression algorithms:
1. -z
uses gzip to compress and decompress files (.tar.gz)
2. -J
uses xz to compress and decompress files (.tar.xz)
3. -j
uses bzip2 to compress and decompress files (.tar.bz2)
Designated function:
1. -c
compression ; create a new archive (compressed package)
2. -x
decompress ; extract files from the compressed package
3. -t
list (list); list the contents of the backup (compressed) file
Other auxiliary parameters:
1. -C destPath
specifies the decompression directory
2. -v lists the processed files in
detail
example
Give some examples:
// .tar.gz文件
tar -zcvf 1.tar.gz a b c // 用gz算法,将 a、b、c 文件/文件夹 **压缩** 为 1.tar.gz 文件
tar -zxvf 1.tar.gz // **解压** 1.tar.gz
tar -zxvf 1.tar.gz -C ~/Desktop // 解压 1.tar.gz 到 桌面
tar -ztvf 1.tar.gz // **列出** 1.tar.gz 文件中的内容
// .tar.xz
tar -Jcvf 1.tar.xz a b c
// .tar.bz2 同上
tar -jcvf 1.tar.bz2 a b c