How to recursively copy directories starting with “abc” on Linux/Unix?

I have a directory ~/plugins/ and inside there are many sub-directories. If I wanted to create a backup somewhere else of just the sub-directories starting with abc could I do that with a one line copy command? I would assume something like this would work (but it doesn't):

cp -R ~/plugins/abc* ~/destination/

I would rather use a one-line command, if possible, because I would also like to use the same syntax for rsync, and if I have to do something like

find ~/plugins/ -type d -name "abc*" -exec cp -R {} ~/destination;

then that works fine for the cp command but it would mean that I would have to run rsync once for each directory and that just doesn't seem efficient :(

39
задан cwd 16 March 2011 в 12:50
поделиться