Copy by extension
Nils Kassube
kassube at gmx.net
Fri Oct 17 17:13:01 UTC 2008
Ed Jabbour wrote:
> I'm looking for an app that will descend into a directory and its subs,
> find all files with a .foo extension and copy them to the bar
> directory. There are a lot of files, so doing it manually would be
> tiresome. If cp has that functionality, I can't find it. Thanks.
Use this:
find -name \*.foo -exec cp {} bar \;
However if you might have multiple files with the same name you will end
up with only one of them in the bar directory. You can check if you have
that problem with this command:
find -name \*.foo -exec basename {} \; | sort | uniq -d
Nils
More information about the ubuntu-users
mailing list