Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Trailing slash in rsync

📅 2016-Oct-01 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ rsync ⬩ 📚 Archive

RSync has some different and confusing behavior depending on whether you put a trailing slash on the source directory or not.

For example:

$ rsync -a /some/path/foobar .
$ ls
foobar/

For example:

$ rsync -a /some/path/foobar/ .
$ ls
content.txt
of.txt
foobar.txt

You do not see such confusing behavior with cp or mv. I guess rsync has this because it is usually used for synchronizing the contents of two directories but it is also sometimes used to copy over directories.