开发者

How does one find and copy files of the same extension, in different directories, to a single directory in linux?

So, How Do I find and copy all files,

*.a 

that are in,

 ~/DIR{1,2,3,...} 

to开发者_运维知识库

 ~/tmp/foo?


Assumed you meant recursively copy everything of type .a from some source location. Haven't verified yet, but this should do that.

find <root-of-search> -type f -name '*.a' -exec cp {} /tmp/foo \;

replace with the top of wherever you want to search from. You might have to throw quotes around *.a, and you might have to replace escape the ending semicolon by putting it in single quotes rather than back-slashing it.


In a bash shell:

cp ~/DIR*/*.a ~/tmp/foo


find ~/DIR{1,2,...} -name *.a print0 | xargs -i -0 cp '{}' ~/tmp/foo
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜