这篇文章给大家介绍如何进行tar打包且排除某个文件,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。有tar打包,有时候需要排除某个文件,本文档提供两种方法来操作。方法一[root@system1 testdir
这篇文章给大家介绍如何进行tar打包且排除某个文件,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
有tar打包,有时候需要排除某个文件,本文档提供两种方法来操作。 |
方法一
[root@system1 testdir]# touch 1 2 3 4 5 6 7 b[root@system1 testdir]# ls1 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]# ls1 2 3 4 5 6 7 a.tar.gz b[root@system1 testdir]# mv a.tar.gz /tmp/test[root@system1 testdir]# ls1 2 3 4 5 6 7 b[root@system1 testdir]# cd ..[root@system1 tmp]# cd test[root@system1 test]# lsa.tar.gz[root@system1 test]# tar -xvf a.tar.gz ./1./2./3./4./5./6./7[root@system1 test]# ls1 2 3 4 5 6 7 a.tar.gz
方法二
[root@system1 testdir]# ls1 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]# ls1 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]# lsa.tar.gz[root@system1 test]# tar -xvf a.tar.gz ./1./2./3./4./5./6./7[root@system1 test]# ls1 2 3 4 5 6 7 a.tar.gz
关于如何进行tar打包且排除某个文件就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
--结束END--
本文标题: 如何进行tar打包且排除某个文件
本文链接: https://www.lsjlt.com/news/244936.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0