返回顶部
首页 > 资讯 > 精选 >如何进行tar打包且排除某个文件
  • 237
分享到

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

2023-06-05 22:06:57 237人浏览 八月长安
摘要

这篇文章给大家介绍如何进行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

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作