bash 找到所有文件,并将它们复制到一个文件夹中(以递归方式展平)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20211911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Find all files, and copy them to a folder (Flatten recursively)
提问by DrDavid
Basically, I have a very large filesystem that contains media. It has a ton of silly subfolders. I'd like to find all the files(any file) and copy them flatly into a directory. What's the best/easiest way to do this?
基本上,我有一个包含媒体的非常大的文件系统。它有大量愚蠢的子文件夹。我想找到所有文件(任何文件)并将它们完全复制到一个目录中。最好/最简单的方法是什么?
assume that the directory of media is located at /home/user/media and the location of the destination directory is /home/user/flatmedia
假设media目录在/home/user/media,目的目录在/home/user/flatmedia
I'd like to do this using standard mac tools.
我想使用标准的 mac 工具来做到这一点。
回答by GS - Apologise to Monica
find /home/user/media -type f -exec cp {} /home/user/flatmedia \;
find /home/user/media -type f -exec cp {} /home/user/flatmedia \;
Note - if there are any duplicates there's no particular guarantee about which one you'll get.
注意 - 如果有任何重复,没有特别保证你会得到哪一个。