linux tar打包压缩排除某个目录或文件

 
更多

用tar打包时想剔除打包目录中的某个子目录或文件:

比如你想打包/home这个目录,但是/home/www.phpernote.com/目录,/home/.git目录和/home/www/test.php文件你都不想打包,方法是:

tar -zcvf home.tar.gz /home --exclude=/home/www.phpernote.com --exclude=/home/.git --exclude=/home/www/test.php

命令格式如下:

tar -zcvf xxx.tar.gz   要打包的目录 –exclude=dir1 –exclude=file1  ……

将一个目录全部打包的命令:

tar -zcvf script.tar.gz ./script/

注:将当前目录下的script目录打包为script.tar.gz文件。

注意:

1、–exclude=file1 而不是 –exclude file1

2、要排除一个目录是 –exclude=dir1,而不是 –exclude=dir1/

打赏

本文固定链接: https://www.cxy163.net/archives/3258 | 绝缘体

该日志由 绝缘体.. 于 2020年05月30日 发表在 未分类 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: linux tar打包压缩排除某个目录或文件 | 绝缘体
关键字: , , , ,

linux tar打包压缩排除某个目录或文件:等您坐沙发呢!

发表评论


快捷键:Ctrl+Enter