【问题标题】:Copy directory structure ignoring some files复制目录结构忽略一些文件
【发布时间】:2017-09-13 20:32:51
【问题描述】:

我有一个目录结构

./
└── file1
   ├── config.xml
   ├── config.yml
   └── file2
       ├── config.xml
       ├── config.yml
       └── file3
           ├── config.xml
           └── config.yml

我想要的是复制相同的目录结构和所有内容,但 忽略新位置中的 config.yml 文件任何 Linux 命令或 脚本提前谢谢

【问题讨论】:

    标签: linux directory structure


    【解决方案1】:

    据我了解,您只想复制文件夹结构,

    你可以这样做:

    find . -type d >dirs.txt

    创建目录列表,然后

    xargs mkdir -p <dirs.txt

    在目标上创建目录。

    看看这个https://stackoverflow.com/a/4073992/6916391

    【讨论】:

    • 我想复制目录结构以及这些目录中的文件,忽略其中的几个
    【解决方案2】:

    您可以通过复制整个结构然后删除 config.yml 文件分两步完成,这是:

    cp -R old_structure_parent_dir new_structure_parent_dir
    find new_structure_parent_dir -name config.yml -exec rm -rf {} \;
    

    【讨论】:

      猜你喜欢
      • 2012-03-31
      • 2011-01-30
      • 2019-10-04
      • 2021-06-07
      • 1970-01-01
      • 2015-02-27
      • 2022-01-25
      • 2017-01-06
      • 1970-01-01
      相关资源
      最近更新 更多