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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Le无忧

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值