zoukankan      html  css  js  c++  java
  • 7-zip的压缩的时候排除某目录

    安装暂且不说了。

    看一下帮助。

    [root@localhost Server]# 7z
    
    7-Zip [64] 9.13 beta  Copyright (c) 1999-2010 Igor Pavlov  2010-04-15
    p7zip Version 9.13 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
    
    Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
           [<@listfiles...>]
    
    <Commands>
      a: Add files to archive
      b: Benchmark
      d: Delete files from archive
      e: Extract files from archive (without using directory names)
      l: List contents of archive
      t: Test integrity of archive
      u: Update files to archive
      x: eXtract files with full paths
    <Switches>
      -ai[r[-|0]]{@listfile|!wildcard}: Include archives
      -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
      -bd: Disable percentage indicator
      -i[r[-|0]]{@listfile|!wildcard}: Include filenames
      -m{Parameters}: set compression Method
      -o{Directory}: set Output directory
      -p{Password}: set Password
      -r[-|0]: Recurse subdirectories
      -scs{UTF-8 | WIN | DOS}: set charset for list files
      -sfx[{name}]: Create SFX archive
      -si[{name}]: read data from stdin
      -slt: show technical information for l (List) command
      -so: write data to stdout
      -ssc[-]: set sensitive case mode
      -t{Type}: Set type of archive
      -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
      -v{Size}[b|k|m|g]: Create volumes
      -w[{path}]: assign Work directory. Empty path means a temporary directory
      -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
      -y: assume Yes on all queries

    记得最苦恼的就是一个排除目录的压缩,后面才明白,由于Linux !有特别的意义,所以要用转义符来使用。

    7z a -t7z tmp.7z curdir -xr!excludedir

     后面一直没弄明白如果我要排除某一类型的文件呢?这又怎么整呢。事实上是需要用到通配符,所以要用以下的命令才对。

    对递归的说明如下:

    -r 递归子目录选项。
    -r 开启递归子目录。对于 e (释放)、l (列表)、t (测试)、x (完整路径释放) 这些在压缩档案中操作的命令, 会默认使用此选项。 
    -r- 关闭递归子目录。对于 a (添加)、d (删除)、u (更新) 等所有需扫描磁盘文件的命令,会默认使用此选项。 
    -r0 开启递归子目录。但只应用于通配符。 

    默认情况下,adu等是关闭了递归扫描所以需要开启进行排除。

    7z a -t7z tmp.7z curdir -xr0!*.log

    如此,便OK了

  • 相关阅读:
    每日一题 为了工作 2020 0330 第二十八题
    每日一题 为了工作 2020 0329 第二十七题
    每日一题 为了工作 2020 0328 第二十六题
    每日一题 为了工作 2020 0325 第二十五题
    每日一题 为了工作 2020 0326 第二十四题
    学习总结(十四)
    学习总结(十三)
    学习总结(十二)
    学习总结(十一)
    学习总结(十)
  • 原文地址:https://www.cnblogs.com/dieangel/p/3513945.html
Copyright © 2011-2022 走看看