【问题标题】:How to exclude a directory and or subdirectory from inclusion using tar on CentOS 6.4如何在 CentOS 6.4 上使用 tar 排除目录和/或子目录
【发布时间】:2013-12-08 21:23:37
【问题描述】:

我已经尝试了所有可以在 Google 上找到的方法,甚至在 stackoverflow 上也可以找到。我知道我可以将文件列表提供给 tar。我想专门使用 tar 命令。

tar cvf fail.tar --exclude=/home/fun/pass1 --exclude=/home/fun/pass2 ../.

无论我尝试什么,使用标记文件,使用单引号、双引号、命令行上的各种定位、通配符等,tar 似乎都忽略了排除参数!

【问题讨论】:

    标签: directory gnu tar centos6


    【解决方案1】:

    这可能是因为您使用绝对路径来创建排除。

    $ touch f1 f2 f3 f4 f5 && ls<br> 
    f1  f2  f3  f4  f5<br>
    $ tar cvf fail.tar --exclude=./f2 --exclude=./f3 ./<br>
    ./<br>
    ./f1<br>
    ./f5<br>
    ./f4<br>
    tar: ./fail.tar: file is the archive; not dumped
    

    【讨论】:

      猜你喜欢
      • 2016-03-02
      • 2014-01-17
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-05
      • 1970-01-01
      • 2012-03-20
      相关资源
      最近更新 更多