Unix - FTSRG/cheat-sheets GitHub Wiki

Trailing slashes

rsync

Rsync has two major modes of operation. The modes are dependent on the absence or presence of the trailing slash on the source directory. Remember: source directory. Trailing slash on the destination directory doesn't matter.

Copy the source directory to the destination (this is the recommended mode; see note below).

rsync -a --delete /home/mst3k /backup/

Copy the contents of the source directory into the destination.

rsync -a --delete /home/mst3k/ /backup/

source

MacOS: default Bash shell

If the source_file ends in a /, the contents of the directory are copied rather than the directory itself.

source

cp and mv

You should not put a trailing slash on the source directory

Use trailing slashes on destination directory

source