安装暂且不说了。

看一下帮助。

[root@localhost Server]# 7z

-Zip [] 9.13 beta  Copyright (c) - Igor Pavlov  --
p7zip Version 9.13 (locale=zh_CN.UTF-,Utf16=on,HugeFiles=on, 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[-|]]{@listfile|!wildcard}: Include archives
-ax[r[-|]]{@listfile|!wildcard}: eXclude archives
-bd: Disable percentage indicator
-i[r[-|]]{@listfile|!wildcard}: Include filenames
-m{Parameters}: set compression Method
-o{Directory}: set Output directory
-p{Password}: set Password
-r[-|]: Recurse subdirectories
-scs{UTF- | 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[-|]]]{@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了

7-zip的压缩的时候排除某目录的更多相关文章

  1. zip & tar 压缩文件时排除某个文件夹

    确实是用参数 -x aaa bbb 两个文件夹要写全路径. 如 zip -r test.zip test -x /test/aaa/* -x /test/bbb/* 既包含了文件夹,也可以 zip - ...

  2. linux 下 zip unzip压缩与解压

    注:*压缩成限.zip格式文件 常用解压缩: [root@mysql test]# unzip -o test.zip -d tmp/ 将压缩文件test.zip在指定目录tmp下解压缩,如果已有相同 ...

  3. Zip文件压缩(加密||非加密||压缩指定目录||压缩目录下的单个文件||根据路径压缩||根据流压缩)

    1.写入Excel,并加密压缩.不保存文件 String dcxh = String.format("%03d", keyValue); String folderFileName ...

  4. 7z压缩文件时排除指定的文件

    分享一个7z压缩文件时排除指定文件类型的命令行,感觉很有用: 7z a -t7z d:\updateCRM.7z d:\updateCRM\*.* -r -x!*.log -x!*bak a:创建压缩 ...

  5. linux下tar、zip等压缩、解压命令

    .tar解包:tar xvf FileName.tar打包:tar cvf FileName.tar DirName(注:tar是打包,不是压缩!)-------------------------- ...

  6. C#执行zip文件压缩的几种方法及我遇到的坑总结

    工作项目中需要用到zip压缩解压缩文件,一开始看上了Ionic.Zip.dll这个类库,操作方便,写法简单 对应有个ziphelper类 using Ionic.Zip; public static ...

  7. 基于ICSharpCode.SharpZipLib.Zip的压缩解压缩

    原文:基于ICSharpCode.SharpZipLib.Zip的压缩解压缩 今天记压缩解压缩的使用,是基于开源项目ICSharpCode.SharpZipLib.Zip的使用. 一.压缩: /// ...

  8. Java用ZIP格式压缩和解压缩文件

    转载:java jdk实例宝典 感觉讲的非常好就转载在这保存! java.util.zip包实现了Zip格式相关的类库,使用格式zip格式压缩和解压缩文件的时候,须要导入该包. 使用zipoutput ...

  9. linux大文件分包压缩和批量解压命令tar // tar 排除指定目录

    压缩命令主要用到tar打包和split分割,命令如下: tar czf - aaa | split -b 1024m - bbb.tar.gz_ aaa可以是文件也可以是目录, 大小可以是b.k.m这 ...

随机推荐

  1. bzoj 2440: [中山市选2011]完全平方数

    #include<cstdio> #include<iostream> #include<cstring> #include<cmath> #defin ...

  2. 【codevs1036】商务旅行 LCA 倍增

    1036 商务旅行  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题目描述 Description 某首都城市的商人要经常到各城镇去做生意,他们按自己的 ...

  3. C++-理解构造函数、析构函数执行顺序

    先初始化序列中的函数调用,如果基类构造函数为非引用传递,则引起参数的拷贝构造 再: 先类内的成员构造函数(拷贝/默认),再类的构造函数:先基类,再派生类: 本文主要说明对象创建时构造函数的执行顺序,对 ...

  4. SSH(1)

    假定服务器ip为192.168.1.139,ssh服务的端口号为22,服务器上有个用户为pi,两边都是ubuntu 一,Init *安装 如果是想用ssh从本机登陆别的机器,只需要安装openssh- ...

  5. App Store--心酸的上线路,说说那些不可思议的被拒理由

    yoyeayoyea 您的应用包括色情内容(色情交易,色情展示). 原因是我们的销售人员,把几张艺术照放在个人相册里(头像),换成卡通头像,通过.    颜小风 被拒很正常 一次通过不正常. 之前上线 ...

  6. 预写式日志WAL

    Chapter 25. 预写式日志(Write-Ahead Logging (WAL)) Table of Contents 25.1. WAL 的好处 25.2. WAL 配置 25.3. 内部 预 ...

  7. 转:Python时间戳和日期的相互转换

    当前时间戳:time.time() 当前日期:time.ctime() 1.Python下日期到时间戳的转换 import datetime import time dateC=datetime.da ...

  8. iOS线程

    昨天在项目中使用到了以前所没有使用过的线程,今天有时间来简单的学习一下. 一.线程的创建分为三种方法 (id)init; // designated initializer (id)initWithT ...

  9. JS 基于面向对象的 轮播图1

    ---恢复内容开始--- 1 'use strict' 2 function Tab(id){ 3 if(!id)return; 4 this.oBox = document.getElementBy ...

  10. 【FreeBuf视频】《安全大咖说》专访知道创宇CTO杨冀龙(watercloud)

    [FreeBuf视频]<安全大咖说>专访知道创宇CTO杨冀龙(watercloud) 发布于 2016/05/16 FreeBuF.COM 杨冀龙,江湖人称watercloud,知道创宇公 ...