资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

如何进行tar打包且排除某个文件

这篇文章给大家介绍如何进行tar打包且排除某个文件,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

唐山网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。创新互联自2013年创立以来到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联

有tar打包,有时候需要排除某个文件,本文档提供两种方法来操作。

方法一

[root@system1 testdir]# touch 1 2 3 4 5 6 7 b
[root@system1 testdir]# ls
1  2  3  4  5  6  7  b
[root@system1 testdir]# tar zcvf a.tar.gz ./* --exclude b
#排除b文件
./1
./2
./3
./4
./5
./6
./7
[root@system1 testdir]# ls
1  2  3  4  5  6  7  a.tar.gz  b
[root@system1 testdir]# mv a.tar.gz /tmp/test
[root@system1 testdir]# ls
1  2  3  4  5  6  7  b
[root@system1 testdir]# cd ..
[root@system1 tmp]# cd test
[root@system1 test]# ls
a.tar.gz
[root@system1 test]# tar -xvf a.tar.gz 
./1
./2
./3
./4
./5
./6
./7
[root@system1 test]# ls
1  2  3  4  5  6  7  a.tar.gz

方法二

[root@system1 testdir]# ls
1  2  3  4  5  6  7  b
[root@system1 testdir]# find ./ -type f ! -name 'b'  | xargs tar caf a.tar.gz
#排除b文件
[root@system1 testdir]# ls
1  2  3  4  5  6  7  a.tar.gz  b
[root@system1 testdir]# mv a.tar.gz /tmp/test
[root@system1 testdir]# cd /tmp/test
[root@system1 test]# ls
a.tar.gz
[root@system1 test]# tar -xvf a.tar.gz 
./1
./2
./3
./4
./5
./6
./7
[root@system1 test]# ls
1  2  3  4  5  6  7  a.tar.gz

关于如何进行tar打包且排除某个文件就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。


本文名称:如何进行tar打包且排除某个文件
本文地址:http://cdkjz.cn/article/geocpi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220