Pay attention to trailing slashes when using rsync

Updated . Posted . Visible to the public. Repeats.

When you synchronize directories with rsync you have to pay attention to use (or not use) trailing /.

Hint

Use rsync -nv to check everything with a dry-run first.

Example:

# without trailing slash
$ mkdir -p a/foo/bar/baz
$ mkdir b
$ rsync -a a b
$ find b
b
b/a
b/a/foo
b/a/foo/bar
b/a/foo/bar/baz

# with trailing slash
$ mkdir -p a/foo/bar/baz
$ mkdir b
$ rsync -a a/ b/
$ find b
b
b/foo
b/foo/bar
b/foo/bar/baz
Last edit
Andreas Vöst
License
Source code in this card is licensed under the MIT License.