According to this web page, adding '/' to the end of an rsync destination produces a different result from not adding it.

I've tried to test this, but I cannot verify it:

$ mkdir dir{1..3}
$ touch dir1/file
$ rsync -r dir1/ dir2
$ rsync -r dir1/ dir3/
$ ls dir*



Does appending a '/' to the destination actually have a use sometimes?

  • Are you referring to this part of the man page: A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination.? If so please note how your command is not at all similar to the one in the example given in the man page.
    – jesse_b
    Nov 4, 2017 at 22:05
  • @Jesse_b Your comment does surprise me... "When using "/" at the end of destination, rsync will paste the data inside the last folder. When not using "/" at the end of destination, rsync will create a folder with the last destination folder name and paste the data inside that folder." Nov 4, 2017 at 22:10
  • @HaukeLaging I'm confused, what is surprising? This particular section also refers to the trailing slash being on the source. So if you did rsync -r dir1/subdir1 dir2/ it will copy the contents of subdir1 into dir2 but if you did rsync -r dir1/subdir1/ dir2/ it will copy the whole directory (including contents) subdir1 into dir2 so you would have ./dir2/subdir1/
    – jesse_b
    Nov 4, 2017 at 22:15
  • @Jesse_b I did not notice the "man" in your first comment. Quite obviously the OP does not refer to the man page but to the page which he has linked. Nov 4, 2017 at 22:32
  • @HaukeLaging Oh duh, didn't even see that. I think I was skimming too fast and read it as "According to the man page".
    – jesse_b
    Nov 4, 2017 at 22:33

1 Answer 1


It does make a difference when the source is a file and the destination directory does not exist. For instance take a file called file as source:

  • $ rsync file dest/ will create a copy of file inside a directory dest, whereas
  • $ rsync file dest will make a copy of the file file called dest

To add (from the comments); if a directory dest already exists, a copy file will be created in dest in both cases above.

Basic example:

~/test > touch file
~/test > mkdir dest1
mkdir: created directory 'dest1'
~/test > tree
├── dest1
└── file

1 directory, 1 file
~/test > rsync file dest1
~/test > rsync file dest2
~/test > rsync file dest3/
~/test > tree
├── dest1
│   └── file
├── dest2
├── dest3
│   └── file
└── file

2 directories, 4 files
~/test >
  • 1
    Thank you. So if directory dest already exists, there's no need for the trailing slash?
    – EmmaV
    Nov 4, 2017 at 22:16
  • Exactly. If in the example above a directory dest exists, a copy of file will be created inside in both cases.
    – resc
    Nov 4, 2017 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.