How can you recursively copy all * .foo files to src for target use with cp and / or find?

cp -v -ur path/to/jsps/ /dest/path/

The above command copies all files that have been updated from the source directory to the destination, preserving the directory structure.

I cannot figure out how to copy only * .someExtention files. I know you can use something like:

find -f -name *.jsp -exec some awesome commands {}

But I don’t know how to do this (and I don’t have time to read the information pages in detail).

All help is appreciated.

Thanks, LES

+3
source share
2 answers

If you want to use find / cp, then the following should do the trick:

find -f -name *.jsp -exec cp --parents {} /dest/path \;

but rsync is probably the best tool.

+7
source

rsync - include exclude,

rsync -a \
   --include='*.foo' \
   --include='*/' \
   --exclude='*' \
   path/to/jsps/ /dest/path/

" " .

+4

Source: https://habr.com/ru/post/1704842/


All Articles