最近有人问我tar压缩能不能不包含不想要的文件或者文件夹 
压缩包很利于传送,备份等等。但比如大量的日志文件一般是不需要备份,或者需要分开备份。 
tar参数中的–exclude,这个是我在看鸟哥私房菜时看到的。当时觉得肯定有用,就多留意了几眼,但使用的时候发现不是那么回事,所以后来就多研究了一下。没想到现在对于备份来说很舒服~~~得心应手,如果要包含其他路径的文件需要使用–include 
例子: 
在我的test文件夹下面,包含一些symbian的sisx安装包及andoid包apk安装包等等 
test的大致目录结构:

[root@**** html]# tree -L 2 test
test
|--AndroidPad_v1.0.0_20111116_online_unsigned_1.apk
::|--KingGoo.Com.sh
|-- PACK_NAME.apk
|-- android.php
|-- androidpad.php
|-- bak
|`-- Vancl_2.0.0.0000_14_20120117_online_unsigned_versionCode_20.apk
|-- debug
|-- head.php
|-- index.php
|-- index1.php
|-- lingxin
|-- make.php
|-- make.sh
|-- make.sh.bk
|-- package.jar
|-- s60V3_1.2.1_2011-08-22-1755_online_signed.sis
::
|-- source_id.txt
|-- symbian.php
|-- temp
| |-- AndroidPhone_v1.3.2_demo_unsign_versionCode7.apk_android
| |-- KingGoo.Com_Err.log
| |-- android
| |-- androidpad
| |-- make.log
| |-- symbian
| `-- temp
`-- test.php 8 directories, 86 files

我不想要*.sis、*.sisx、*.apk则:

[root@**** html]# tar -czvf  test.tar.gz  test --exclude=test/*.sisx  --exclude=test/*.apk --exclude=test/temp/* --exclude=test/*.sis
test/
test/temp/
test/make.sh
test/package.jar
test/android.php
test/head.php
test/test.php
test/make.sh.bk
test/make.php
test/source_id.txt
test/index.php
test/index.php.bkkkk
test/KingGoo.Com.sh
test/bak/
test/index.php.bk
test/symbian.php
test/debug/
test/index.php.bkk
test/index1.php
test/index.php.bkkk
test/androidpad.php
test/lingxa

查看一下,压缩包内的文件(非解压)

[root@**** html]# tar  -tf  test.tar.gz
test/
test/temp/
test/make.sh
test/package.jar
test/android.php
test/head.php
test/test.php
test/make.sh.bk
test/make.php
test/source_id.txt
test/index.php
test/index.php.bkkkk
test/KingGoo.Com.sh
test/bak/
test/index.php.bk
test/symbian.php
test/debug/
test/index.php.bkk
test/index1.php
test/index.php.bkkk
test/androidpad.php
test/lingxa

版权声明:

转载原创文章请注明,文章出处:http://kinggoo.com
原文地址:http://kinggoo.com/linux-tarexlude.htm

tar 的–exclude参数,实现不包括某些文件(转)的更多相关文章

  1. Linux tar命令之--exclude参数 排除指定的文件或目录

    https://my.oschina.net/u/3285916/blog/1632552 参数: --exclude 打包时排除不需要处理的文件或目录 说明: tar -zcf a.tar.gz 打 ...

  2. solaris tar 命令exclude使用

    压缩时需要排除指定目录,不知道什么原因在solaris中 tar cvf a.tar a --exclude=a/b/log --exclude = a/c/mm7log不生效, 最后使用了如下方法 ...

  3. linux下tar gz bz2 tgz z等众多压缩文件的压缩与解压方法

    Linux下最常用的打包程序就是tar了,使用tar程序打出来的包我们常称为tar包,tar包文件的命令通常都是以.tar结尾的.生成tar包后,就可以用其它的程序来进 行压缩了,所以首先就来讲讲ta ...

  4. 使用ajax提交form表单,包括ajax文件上传 转http://www.cnblogs.com/zhuxiaojie/p/4783939.html

    使用ajax提交form表单,包括ajax文件上传 前言 使用ajax请求数据,很多人都会,比如说: $.post(path,{data:data},function(data){ ... },&qu ...

  5. 使用ajax提交form表单,包括ajax文件上传【转载】

    [使用ajax提交form表单,包括ajax文件上传] 前言 转载:作者:https://www.cnblogs.com/zhuxiaojie/p/4783939.html 使用ajax请求数据,很多 ...

  6. Netbeans打开包括中文文件时提示错误

    Netbeans打开包括中文文件时提示错误.在Netbeans里找了半天没找到怎么设置,最后发现要改动Netbeans的配置文件才干解决. 编辑C:\Program Files\NetBeans 8. ...

  7. C语言宏定义技巧——多次包括头文件内容不同

    1.  头文件定义例如以下: /* declears in "funcs.h" */ FUNC_1(ID_FUN1_001) FUNC_1(ID_FUN1_002) FUNC_2( ...

  8. 利用Xilinx ROM仿真时注意包括.mif文件

    利用Xilinx ROM仿真时,注意包括.mif文件.一般是将.v文件和.mif文件放在同一个目录下,以便.v文件读取.mif数据.如不注意,就不会读出有效数据.

  9. Linux tar命令exclude选项排除指定文件或目录

    在linux中可以用tar打包目录以方便传输or备份,我们先来看一个例子 test 文件夹有如下文件 [root@lee ~]# ll test 总用量 -rw-r--r--. root root 4 ...

随机推荐

  1. 《转》CXF WebService 开发文档-目录索引

    CXF WebService 开发文档-目录索引 上次介绍了Axis的WebService,现在我们来看看CXF是怎么完成WebService的. Axis1 WebService 在线博文: htt ...

  2. poj 1321 棋盘问题(n行中放任意k行)

    n*n的棋盘摆K的棋子,任意两个棋子不能在同一行同一列 Sample Input 2 1#.  //# 可放.#4 4...#..#..#..#...-1 -1Sample Output 21 # i ...

  3. webpack 使用环境变量

    要在开发和生产构建之间,消除 webpack.config.js 的差异.你可能需要环境变量. 可以使用 Node.js 模块的标准方式:在运行 webpack 时设置环境变量,并且使用 Node.j ...

  4. [转] 插件兼容CommonJS, AMD, CMD 和 原生 JS

    模块标准 CommonJS CommonJS 有三个全局变量 module.exports 和 require.但是由于 AMD 也有 require 这个全局变量,故不使用这个变量来进行检测. 如果 ...

  5. PTA 7-2 是否完全二叉搜索树(30 分) 二叉树

    将一系列给定数字顺序插入一个初始为空的二叉搜索树(定义为左子树键值大,右子树键值小),你需要判断最后的树是否一棵完全二叉树,并且给出其层序遍历的结果. 输入格式: 输入第一行给出一个不超过20的正整数 ...

  6. hdu-1754 I Hate It【线段树】(求区间最大值)

    <题目链接> I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  7. poj2230 Watchcow【欧拉回路】【输出路径】(遍历所有边的两个方向)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4392 题目大意: 一个图,要将每条边恰好遍历两遍,而且要以不同的方向,还要回到原点. dfs解法    ...

  8. Hash值破解工具Hashcat使用

    Hash值破解工具Hashcat使用 Hashcat介绍 HashCat系列软件拥有十分灵活的破解方式,可以满足绝大多数的破解需求. Hashcat系列软件是比较牛逼的密码破解软件,系列软件包含Has ...

  9. js实现移动端图片预览:手势缩放, 手势拖动,双击放大...

    .katex { display: block; text-align: center; white-space: nowrap; } .katex-display > .katex > ...

  10. HDU.2829.Lawrence(DP 斜率优化)

    题目链接 \(Description\) 给定一个\(n\)个数的序列,最多将序列分为\(m+1\)段,每段的价值是这段中所有数两两相乘的和.求最小总价值. \(Solution\) 写到这突然懒得写 ...