tar 的–exclude参数,实现不包括某些文件(转)
最近有人问我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参数,实现不包括某些文件(转)的更多相关文章
- Linux tar命令之--exclude参数 排除指定的文件或目录
https://my.oschina.net/u/3285916/blog/1632552 参数: --exclude 打包时排除不需要处理的文件或目录 说明: tar -zcf a.tar.gz 打 ...
- solaris tar 命令exclude使用
压缩时需要排除指定目录,不知道什么原因在solaris中 tar cvf a.tar a --exclude=a/b/log --exclude = a/c/mm7log不生效, 最后使用了如下方法 ...
- linux下tar gz bz2 tgz z等众多压缩文件的压缩与解压方法
Linux下最常用的打包程序就是tar了,使用tar程序打出来的包我们常称为tar包,tar包文件的命令通常都是以.tar结尾的.生成tar包后,就可以用其它的程序来进 行压缩了,所以首先就来讲讲ta ...
- 使用ajax提交form表单,包括ajax文件上传 转http://www.cnblogs.com/zhuxiaojie/p/4783939.html
使用ajax提交form表单,包括ajax文件上传 前言 使用ajax请求数据,很多人都会,比如说: $.post(path,{data:data},function(data){ ... },&qu ...
- 使用ajax提交form表单,包括ajax文件上传【转载】
[使用ajax提交form表单,包括ajax文件上传] 前言 转载:作者:https://www.cnblogs.com/zhuxiaojie/p/4783939.html 使用ajax请求数据,很多 ...
- Netbeans打开包括中文文件时提示错误
Netbeans打开包括中文文件时提示错误.在Netbeans里找了半天没找到怎么设置,最后发现要改动Netbeans的配置文件才干解决. 编辑C:\Program Files\NetBeans 8. ...
- C语言宏定义技巧——多次包括头文件内容不同
1. 头文件定义例如以下: /* declears in "funcs.h" */ FUNC_1(ID_FUN1_001) FUNC_1(ID_FUN1_002) FUNC_2( ...
- 利用Xilinx ROM仿真时注意包括.mif文件
利用Xilinx ROM仿真时,注意包括.mif文件.一般是将.v文件和.mif文件放在同一个目录下,以便.v文件读取.mif数据.如不注意,就不会读出有效数据.
- Linux tar命令exclude选项排除指定文件或目录
在linux中可以用tar打包目录以方便传输or备份,我们先来看一个例子 test 文件夹有如下文件 [root@lee ~]# ll test 总用量 -rw-r--r--. root root 4 ...
随机推荐
- HDU1711 Number Sequence(KMP模板题)
Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- kotlin 插件更新到 1.2.41 程序出错 Please use kotlin-stdlib-jdk7 instead
buildscript { ext.kotlin_version = '1.2.41' repositories { google() jcenter() } dependencies { class ...
- openstack学习-glance安装(三)
glance在openstack负责镜像相关管理的,对外提供标准的api提供服务,glance有两个服务,一个是glance-api接受云系统镜像的创建.删除.读取请求.glance-registry ...
- copy 深浅复制
- 在phpstorm中svn的使用
目 录 1.搭建svn环境 1.1搭建svn服务端 1.2创建svn用户和密码 2.开始在phpstorm中链接svn 2.1打开Subversion 2.2 输入svn地址 2.3选择导出文件,进 ...
- 洛谷 P1135 奇怪的电梯 【基础BFS】
题目链接:https://www.luogu.org/problemnew/show/P1135 题目描述 呵呵,有一天我做了一个梦,梦见了一种很奇怪的电梯.大楼的每一层楼都可以停电梯,而且第 i 层 ...
- Android高效内存2:让图片占用尽可能少的内存
Android高效内存:让图片占用尽可能少的内存 一.让你的图片最小化 1.1 大图小图内存使用情况对比 大图:440 * 336 小图:220 * 168 资源目录:xhdpi 小图的高宽都是 ...
- win7 资源资源管理器访问FTP站点
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\ftp] @="URL:File Transfer Protocol" ...
- 用Python破解斗地主残局
相信大家都玩过斗地主,规则就不再介绍了. 直接上一张朋友圈看到的残局图: 这道题我刚看到时,曾尝试用手工来破解,每次都以为找到了农民的必胜策略时,最后都发现其实农民跑不掉.由于手工破解无法穷尽所有可能 ...
- BZOJ 4805: 欧拉函数求和 杜教筛
https://www.lydsy.com/JudgeOnline/problem.php?id=4805 给出一个数字N,求sigma(phi(i)),1<=i<=N https://b ...