How to copy a directory to another while excluding some specific directories

Don't use cp, use rsync instead:

rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude

You can use PATTERN to exclude your files or directories.
--exclude=PATTERN       exclude files matching PATTERN

You can also use filter to exclude:
 -f, --filter=RULE
              This  option  allows you to add rules to selectively exclude certain files from the list of files to be transferred. This is most
              useful in combination with a recursive transfer.

              You may use as many --filter options on the command line as you like to build up the list of files to  exclude.   If  the  filter
              contains  whitespace,  be  sure  to quote it so that the shell gives the rule to rsync as a single argument.  The text below also

              mentions that you can use an underscore to replace the space that separates a rule from its arg.


Popular posts from this blog

How to get Active Transactions and Locks from MySQL

Example of a PAC file