«

Linux 压缩/解压

Le无忧 发布于 阅读:302 Linux


  1. tar格式压缩和解压
    (1)打包归档格式:
    tar -cvf examples.tar files|dir

    说明:

    -c, --create create a new archive 创建一个归档文件
    -v, --verbose verbosely list files processed 显示创建归档文件的进程
    -f, --file=ARCHIVE use archive file or device ARCHIVE 后面要立刻接被处理的档案名,比如--file=examples.tar
    #举例:
    tar -cvf file.tar file1 #file1文件
    tar -cvf file.tar file1 file2 #file1,file2文件
    tar -cvf file.tar dir #dir目录            (__OK)

    (2)释放解压格式:
    tar -xvf examples.tar (解压至当前目录下)
    tar -xvf examples.tar -C /path (/path 解压至其它路径)

    说明:

    -x, --extract, extract files from an archive 从一个归档文件中提取文件
    #举例:
    tar -xvf file.tar        (__OK)
    tar -xvf file.tar -C /temp #解压到temp目录下        (__OK   /最顶根目录) /home/admin/test/
  2. tar.gz tgz (tar.gz和tgz只是两种不同的书写方式
    (1)打包压缩格式:
    tar -zcvf examples.tgz examples (examples当前执行路径下的目录)
    说明:
    -z, --gzip filter the archive through gzip 通过gzip压缩的形式对文件进行归档
    举例:

tar -zcvf file.tgz dir #dir目录 __OK

(2)释放解压格式:
    tar -zxvf examples.tar (解压至当前执行目录下)
    tar -zxvf examples.tar -C /path (/path 解压至其它路径)
    举例:
    tar -zcvf file.tgz            (__OK)
    tar -zcvf file.tgz -C /temp    (__OK)

3 .tar.bz
(1)打包压缩格式:
tar -jcvf examples.tar.bz2 examples (examples为当前执行路径下的目录)
说明:
-j, --bzip2 filter the archive through bzip2 通过bzip2压缩的形式对文件进行归档
举例:

tar -jcvf file.tar.bz2 dir #dir目录 __OK

(2)释放解压:
tar -jxvf examples.tar.bz2 (解压至当前执行目录下)
tar -jxvf examples.tar.bz2 -C /path (/path 解压至其它路径)
举例:
tar -jxvf file.tar.bz2                    (__OK)
tar -jxvf file.tar.bz2 -C /temp

4 .gz
压缩:gzip -d examples.gz examples
解压:gunzip examples.gz

5 .zip
压缩:zip -r examples.zip examples (examples为目录)
解压:zip examples.zip

6 .rar
压缩:rar -a examples.rar examples
解压:rar -x examples.rar
————————————————
版权声明:本文为CSDN博主「Le无忧」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/WXN889/article/details/124126776


扫描二维码,在手机上阅读

推荐阅读:

收藏