开发者

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

开发者 https://www.devze.com 2022-12-30 12:10 出处:网络
So,How Do I find and copy all files, *.a that are in, ~/DIR{1,2,3,...} to开发者_运维知识库 ~/tmp/foo?

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

精彩评论

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