最近有人问我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. HDU1730 Northcott Game 尼姆博弈

    Northcott Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  2. 【C++ Primer 第11章 练习答案】2. 关联容器操作

    11.3.1节练习 [练习11.16]代码 map<int, int> m; auto iter = m.begin(); iter ->second = ;

  3. 单一职责原则(Simple responsibility pinciple, SRP)

    一个类只负责一个功能领域中的相应职责 未完待续

  4. 大数据统计分析平台之二、ElasticSearch 6.2.1的安装与使用

    # 下载文件cd /usr/local/software wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch ...

  5. Educational Codeforces Round 26-D. Round Subset

    题目大意:给你n个数字(小于1e18),从n个数中取k个数字相乘,使其后缀0最多,问你后缀0最多是多少. 知道得用三维的dp[ i ] [ j ] [ k ]  第一维表示用到第 i 个数为止,j 表 ...

  6. Codeforces 385D - Bear and Floodlight

    385D - Bear and Floodlight 题目大意:有一个人从( l , 0 ) 想走到 ( r , 0 ),有 n 盏路灯,位置为( xi , yi ),每盏路灯都有一个照射的角度ai ...

  7. thinkphp中AJAX返回ajaxReturn()方法分析

    本文分析了thinkphp中AJAX返回ajaxReturn()方法.分享给大家供大家参考,具体如下: 系统支持任何的AJAX类库,Action类提供了ajaxReturn方法用于AJAX调用后返回数 ...

  8. 6-7 树的层次遍历 uva122

    非常不熟练  照着书大的 晚上尝试一下自己打  了解二叉树  用数组打 第一次: #include<bits/stdc++.h> using namespace std; bool fai ...

  9. Manjaro 初始配置----anaconda-pycharm-opencv-tensorflow

    1.安装蟒蛇 1)安装 yaourt anaconda source /opt/anaconda/bin/active root 2)添加环境变量 在〜/ .bashrc中添加 export PATH ...

  10. docker 部署springboot应用

    第一步:搭建springboot的web应用,可在CMD命令行中通过mvn install命令将应用打成jar包:如demo-0.0.1-SNAPSHOT.jar 第二步:将jar包copy到cent ...