Copy nested directory structure ignoring all directories of a certain name

cprsync

Say I have a big nested directory projects/ and I want to recursively copy the entire directory excluding any sub-directory with the name node_modules/ or env/.

I don't know how many node_modules/ or env/ directories there are and they can be at any level in the projects/ tree. I.e. there could be a projects/project-1/env/ and a projects/project-2/app/node_modules.

How would I go about doing this?

Best Answer

rsync -rv --exclude=node_modules --exclude=env /projects /destination
Related Question