cp dir recursivly excluding 2 subdirs cp dir recursivly excluding 2 subdirs unix unix

cp dir recursivly excluding 2 subdirs


rsync -avz --exclude subdirectory5 --exclude subdirectory7 /home/directory/ target-path


I don't know a good way of doing it with cp, but it's fairly easy using rsync and the --exclude switch.


Maybe the find command will help you:

$ find /home/directory -mindepth 1 -maxdepth 1 -name 'subdirectory[57]' -or -exec cp -r {} /path/to/dir \;