linux 压缩排除某个文件夹,linux tar压缩排除 某类型文件 某个文件夹
排除某类型文件
测试 生成10个.log文件
再生成10个.txt文件
touch {1..10}.log
touch {1..10}.txt
打包并排除 log结尾的文件
tar -zcvf 1.tar –exclude=*.log .
结论
tar -tvf 1.tar
rwxr-xr-x root/root 0 2018-10-26 02:45 ./
-rw-r–r– root/root 0 2018-10-26 02:45 ./1.txt
-rw-r–r– root/root 0 2018-10-26 02:45 ./2.txt
-rw-r–r– root/root 0 2018-10-26 02:45 ./3.txt
-rw-r–r– root/root 0 2018-10-26 02:45 ./4.txt
-rw-r–r– root/root 0 2018-10-26 02:45 ./5.txt
-rw-r–r– root/root 0 2018-10-26 02:45 ./6.txt
-rw-r–r– root/root 0 2018-10-26 02:45 ./7.txt
-rw-r–r– root/root 0 2018-10-26 02:45 ./8.txt
-rw-r–r– root/root 0 2018-10-26 02:45 ./9.txt
-rw-r–r– root/root 0 2018-10-26 02:45 ./10.txt
以上内容不包括 log 类型文件。成功
例如:
我们以tomcat 为例,打包的时候我们要排除 tomcat/logs 目录,命令如下:
tar -zcvf tomcat.tar.gz –exclude=tomcat/logs tomcat
如果要排除多个目录,增加 –exclude 即可,如下命令排除logs和libs两个目录及文件xiaoshan.txt:
tar -zcvf tomcat.tar.gz –exclude=tomcat/logs –exclude=tomcat/libs –exclude=tomcat/xiaoshan.txt tomcat
这里大家要注意的时候,在我们使用tar 的–exclude 命令排除打包的时候,不能加“/”,否则还是会把logs目录以及其下的文件打包进去。
错误写法:
tar -zcvf tomcat.tar.gz –exclude=tomcat/logs/ –exclude=tomcat/libs/ tomcat
正确写法:
tar -zcvf tomcat.tar.gz –exclude=tomcat/logs –exclude=tomcat/libs tomcat
———————
作者:catoop
来源:CSDN
原文:https://blog.csdn.net/catoop/article/details/40651947
版权声明:本文为博主原创文章,转载请附上博文链接!
linux 压缩排除某个文件夹,linux tar压缩排除 某类型文件 某个文件夹相关推荐
- linux cp 排除文件,cp、tar命令排除文件和子目录 - 米扑博客
测试树形目录 $ cd mimvp-blog/ $ tree . |____111.txt |____222.txt |____333.txt |____folder01 | |____111.txt ...
- Linux 文件打包(tar命令——怎么使打包后的文件夹里只有想要的文件而不是有多一个原目录)
正常打包情况下,打包后的目录下还有个原目录,如下: 怎么去掉这个多余的文件夹呢?如下tar -cvf config.tar -C config/ . 打包包含隐藏目录的文件夹:tar -cvf ...
- Linux中移动,复制,删除,打包排除某个目录或文件
1.移动,复制,删除排除某个文件或目录 cp !(file1|dir2) /data/ 复制文件到/data/,排除file1和dir2 mv !(file1|dir2) /data/ 移动文件到/d ...
- 【第八章】文件与文件系统的压缩、打包与备份
文章目录 压缩文件的用途与技术 Linux系统常见的压缩指令 gzip, zcat/zmore/zless/zgrep bzip2,bzcat/bzmore/bzless/bzgrep xz,xzca ...
- wget下载与tar压缩/解压
文章目录 wget命令 下载整个网站 压缩与解压 小节 wget命令 Usage: wget [OPTION]... [URL]... # 后台运行 -b, --background go to ba ...
- string类型需要头文件?
string类型的变量不需要头文件! 1.string类型的变量是什么? 2.常用的string类型的头文件有哪些? 3.为什么string类型不需要头文件? 4.实例图片 1.string类型的变量 ...
- linux zip压缩排除目录,linux tar压缩排除某个文件夹的方法
一般直接用tar命令打包很简单,直接使用 tar -zcvf test.tar.gz test 即可. 在很多时候,我们要对某一个目录打包,而这个目录下有几十个子目录和子文件,我们需要在打包的时候排除 ...
- linux打压缩包去掉某个文件夹,linux tar压缩排除某个文件夹的方法
一般直接用tar命令打包很简单,直接使用 tar -zcvf test.tar.gz test 即可. 在很多时候,我们要对某一个目录打包,而这个目录下有几十个子目录和子文件,我们需要在打包的时候排除 ...
- linux 7z打包排除特殊文件夹,7-zip的压缩的时候排除某目录
安装暂且不说了. 看一下帮助. [root@localhost Server]# 7z -Zip [] 9.13 beta Copyright (c) - Igor Pavlov -- p7zip V ...
- linux右键无法解压gz文件夹,Linux/centos下zip、tar、gz压缩解压命令
Linux下的压缩解压缩命令详解及实例 实例:压缩服务器上当前目录的内容为xxx.zip文件 zip -r xxx.zip ./* 解压zip文件到当前目录 unzip filename.zip == ...
最新文章
- 9款精致HTML5/jQuery日历时钟控件源码下载(源码请见百度云) 链接:http://pan.baidu.com/s/1geIXe75 密码:7m4a...
- 专家首次释疑“接触传播”:手污染到病毒后,再揉眼睛可能会感染
- 开源网络备份软件bacula(安装bacula)
- JS 控制RadioButtonList 获得上传文件类型后选中
- 远程工作时的协作工具
- mysql 子字符串函数_MySQL 内置字符串函数
- dlna和miracast可以共存吗_高考化学必备之离子共存问题
- Qt工作笔记-QTableWidget设置委托(使用QStyledItemDelegate画3只小猪)
- fastboot no permission
- php setjmp longjmp,我本来以为setjmp和longjmp的实现很复杂【附代码】
- 解决:configure: error: Missing Xext.h, maybe to install libxext-dev packages?
- 代码段:js表单提交检测
- 吉林大学超星学习通高级语言程序设计(C语言)(22秋季)作业实验00
- python colorsys模块 RGB和其他色彩系统(颜色空间)(YIQ、HLS、HSV)之间的转换 hsv_to_rgb(h, s, v)函数
- 纳什均衡定义、举例、分类
- Linux通过df命令查看显示磁盘空间满,但实际未占用问题
- 记录常用正则表达式(亲测,有用)
- ubuntu18.04系统安装+基本环境配置【原创】
- 软件设计:“度”、“裁剪”与“变通”
- 《途客圈创业记:不疯魔,不成活》一一2.3 早期产品
热门文章
- 不同编程语言之间的具体实现对比
- c语言中struct和c++中class实例对比
- 【UML建模】UML图详细总结
- 算法最少分组法_数据结构
- 机器学习常用术语词汇表
- 如何用python读取文本中指定行的内容
- Keras框架下的保存模型和加载模型
- pytorch系列 -- 9 pytorch nn.init 中实现的初始化函数 uniform, normal, const, Xavier, He initialization...
- 用gogs搭建属于自己的git网站
- TypeError: sequence item 1: expected str instance, int found