其他分享
首页 > 其他分享> > 7z

7z

作者:互联网

  

7z的选项设计实在太脑残了,只能说太难用

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]

 

Command:

  1. a 压缩
    7z a bb.7z /etc/security  # 带security目录
    7z a bb.7z /etc/security/*  # 不带security目录

    !!!!!! 如果 压缩文件已经存在则会向压缩文件中添加新的内容,不会覆盖原压缩文件
    指定的文件名后缀决定了压缩格式,后缀名不对,直接报错

  2. l 查看压缩文件
    7z l bb.7z

     

  3. t test 测试压缩文件完整性
    7z t bb.7z

     

  4. b benchmark
    7z b

     

  5. x 解压
    7z x bb.7z -o/media

     

  6. h 生成文件CRC32校验码
    7z h file

     

Switches:

  1. -snl Store symbolic links
    no-dereference Symbolic links
  2. -o/dir 解压目录
    7z x -o/media bb.7z
  3. -x 排除文件,很坑的是使用了 ! ,! 在Linux是Event Designator是有特殊含义的,所有必须转义,在Windows命令行中不需要
    7z a -xr\!*.conf aa.7z /etc/security/*

     

     

  4. -si Read data from stdin
    -so stdout
    与tar 结合使用
    tar cvpPzf - --exclude="*.conf" /etc/security | 7z a -si ab.tar.7z

     

    缺点是使用 tar 的t选项无法查看修改添加文件了

    7z x -so ab.tar.7z |  tar xzf - --directory=/media

     

     

标签:tar,压缩文件,etc,bb.7,security,7z
来源: https://www.cnblogs.com/dissipate/p/14038162.html