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,...}
~/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
精彩评论