博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
tar 的–exclude参数,实现不包括某些文件(转)
阅读量:4555 次
发布时间:2019-06-08

本文共 1837 字,大约阅读时间需要 6 分钟。

最近有人问我tar压缩能不能不包含不想要的文件或者文件夹 

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

[root@**** html]# tree -L 2 testtest|--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.php8 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/*.sistest/test/temp/test/make.shtest/package.jartest/android.phptest/head.phptest/test.phptest/make.sh.bktest/make.phptest/source_id.txttest/index.phptest/index.php.bkkkktest/KingGoo.Com.shtest/bak/test/index.php.bktest/symbian.phptest/debug/test/index.php.bkktest/index1.phptest/index.php.bkkktest/androidpad.phptest/lingxa

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

[root@**** html]# tar  -tf  test.tar.gz test/test/temp/test/make.shtest/package.jartest/android.phptest/head.phptest/test.phptest/make.sh.bktest/make.phptest/source_id.txttest/index.phptest/index.php.bkkkktest/KingGoo.Com.shtest/bak/test/index.php.bktest/symbian.phptest/debug/test/index.php.bkktest/index1.phptest/index.php.bkkktest/androidpad.phptest/lingxa

版权声明:

转载原创文章请注明,文章出处:
原文地址:

转载于:https://www.cnblogs.com/xiangxiaodong/p/3573209.html

你可能感兴趣的文章
网络流 Edmons-Karp 算法讲解
查看>>
「NOIP2018模拟9.10」公约数 - 找规律 - gcd
查看>>
使用java理解程序逻辑(15)
查看>>
bzoj 1879 状压dp
查看>>
python 一些特殊用法和坑
查看>>
WIFI密码破解全攻略
查看>>
c++string各种函数
查看>>
errno.h含义
查看>>
字典树(模型体)
查看>>
盒模型详解
查看>>
bzoj2157 旅游
查看>>
bzoj5016 [Snoi2017]一个简单的询问
查看>>
poj2417 bzoj3239 Discrete Logging(bsgs)
查看>>
UVa10054 - The Necklace(欧拉回路【输出带来的麻烦)
查看>>
string和stringbuffer的区别 集合的作用 ArrayList vector linklist hashmap hashtable collection和collections...
查看>>
6月27日 ajax
查看>>
iOS开发之画图板(贝塞尔曲线)
查看>>
4嵌入式作业io
查看>>
IntelliJ Idea编译报错:javacTask: 源发行版 1.7 需要目标发行版 1.7
查看>>
Cognos中新建SQLserver数据源的步骤
查看>>