Copy by extension

Nils Kassube kassube at gmx.net
Tue Oct 21 14:28:09 UTC 2008


Neil wrote:
> > 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.
>
> just curious: would cp -R *.foo /path/to/destination/ do the trick? Or
> would it recreate the directory structure in the destination
> directory?

If you are curious how the cp command works, why don't you just try what 
it does? The experiment will give you a much better knowledge than any 
answer from the list.

mkdir -p ~/test/source ~/test/destination
cd ~/test/source
mkdir -p dir1 dir2.foo/dir3 
touch file1 file2.foo dir1/file3.foo dir2.foo/dir3/file3
cp -R *.foo ~/test/destination
find ~/test -exec ls -Fd {} \; | sort

Now if you can't find out _why_ it works the way it does, please come back 
and ask again.


Nils




More information about the ubuntu-users mailing list