Linux decompression and compression

tar

  • Independent command, one of them will be used for decompression or compression and only one at the same time
    -c: 建立压缩档案 
    -x:解压 
    -t:查看内容 
    -r:向压缩归档文件末尾追加文件 
    -u:更新原压缩包中的文件
    
  • Optional parameters
    -z:有gzip属性的 
    -j:有bz2属性的 
    -Z:有compress属性的 
    -v:显示所有过程 
    -O:将文件解开到标准输出 
    
  • Required parameters
    -f: 最后一个参数,后面只能接档案名。
    

Unzip

tar -xvf file.tar         // 解压 *.tar 
tar -xzvf file.tar.gz     // 解压 *.tar.gz
tar -xjvf file.tar.bz2    // 解压 *.tar.bz2
tar -xZvf file.tar.Z      // 解压 *.tar.Z
unrar e file.rar          // 解压 *.rar
unzip file.zip            // 解压 *.zip

compression

tar -cvf jpg.tar *.jpg       // 将目录里所有jpg文件打包成 tar.jpg 
tar -czf jpg.tar.gz *.jpg    // 将目录里所有jpg文件打包成 jpg.tar 后,并且将其用 gzip 压缩,生成一个 gzip 压缩过的包,命名为 jpg.tar.gz 
tar -cjf jpg.tar.bz2 *.jpg   // 将目录里所有jpg文件打包成 jpg.tar 后,并且将其用 bzip2 压缩,生成一个 bzip2 压缩过的包,命名为jpg.tar.bz2 
tar -cZf jpg.tar.Z *.jpg     // 将目录里所有 jpg 文件打包成 jpg.tar 后,并且将其用 compress 压缩,生成一个 umcompress 压缩过的包,命名为jpg.tar.Z 
rar a jpg.rar *.jpg          // rar格式的压缩,需要先下载 rar for linux 
zip jpg.zip *.jpg            // zip格式的压缩,需要先下载 zip for linux

For other zip and rar decompression and compression related knowledge, please refer to the link below.
Reference: Linux tar.gz, tar, bz2, zip and other decompression and compression commands in detail

Guess you like

Origin blog.csdn.net/nongminkouhao/article/details/108119809