How do I exclude a folder when performing file operations i.e. cp, mv, rm and chown etc. in Linux

Solution 1:

Inverse Globbing:
You want an inverse match of a glob, I would do it like the following:

You can do an inverse match with a newer bash if you enable extended globbing. For example, to match everything that doesn't have foo or bar in the name:

shopt -s extglob
echo !(*foo*|*bar*)

Or just everything that doesn't have foo:

shopt -s extglob
echo !(*foo*)

Find:
You could also use find (this is the most robust option I think), and use ! to negate a match, and then run the command with xargs -0:

find . ! -iname 'foo' -print0 | xargs -0 echo

Simple:
Just mv the folder somewhere else, do what you need to do, and put it back :-)

Solution 2:

rsync -arv --exclude={files} {Destination}