试图根据特定指南将文件复制到新目录

时间:2015-09-21 23:08:30

标签: linux find cp

我试图将所有以大写字母开头的文件夹中的文件复制到另一个文件夹中。

到目前为止,我已经使用find命令实际查找文件

find /examplefolder -type f -name "[[:upper:]]*"

并且我能够发现它们没有问题

我尝试将command替换为cp,但这不起作用,然后我尝试输入cp命令,但我又失败了

2 个答案:

答案 0 :(得分:0)

使用-exec选项查找

find /examplefolder -type f -name "[[:upper:]]*" -exec cp {} /my/new/shiny/folder/ \; 

答案 1 :(得分:0)

我能够通过使用xargs和-I参数

连接到cp来实现

find / examplefolder -type f -name" [[:upper:]] *" | xargs -I%cp%/ copied_directory