【问题标题】:I want to only the contents of directories and his subdirectories to a directory without copying the directory and subdirectory我只想将目录及其子目录的内容复制到一个目录而不复制目录和子目录
【发布时间】:2021-02-10 21:11:15
【问题描述】:

输入:-

我有一个目录也包含子目录,子目录也包含一些这样的数据。

test/abc/def/file1.txt

test/abc/file2.txt

test/file3.txt

我需要像这样在一个目录中的所有文件

意味着我需要子目录中的所有数据到一个文件夹

输出:-

test2/file1.txt

test2/file2.txt

test2/file3.txt

【问题讨论】:

  • 文件名重复怎么办?

标签: linux


【解决方案1】:
  1. 查找所有文件:

    find source/ -type f
    
  2. 将多个文件复制到一个目录:

    cp -t target/ files...
    
  3. 结合两个命令:

    find source/ -type f -exec cp -t target/ '{}' +
    
  4. 利润

【讨论】:

    猜你喜欢
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-07
    • 2012-07-24
    • 1970-01-01
    • 2020-09-06
    • 1970-01-01
    相关资源
    最近更新 更多