• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Solved With / or not behind the directory



Thanks: 4
Messages: 95


I found two following syntax resulted in different file transfer consequences.

Please compare

rsync -Phr "/Volumes/Data/StarCraft II" admin@

rsync -Phr "/Volumes/Data/StarCraft II/" admin@
Some one know the difference between /xxx/xxx/path and /xxx/xxx/path/? What difference does the final / make?

Much appreciated!



Thanks: 452
Messages: 1,275

rsync /source/ /dest/
This will sync the files in the source directory into dest

rsync /source /dest/
rsync /source /dest
This will sync the source directory itself into dest, so you'll end up with a subdirectory /dest/source containing the data.


Aspiring Daemon

Thanks: 347
Messages: 871

from rsync(1):
              rsync -avz foo:src/bar /data/tmp

       This would recursively transfer all files from the directory src/bar on
       the machine foo into the /data/tmp/bar directory on the local machine.
       The files are transferred in "archive" mode, which ensures that
       symbolic links, devices, attributes, permissions, ownerships, etc. are
       preserved in the transfer.  Additionally, compression will be used to
       reduce the size of data portions of the transfer.

              rsync -avz foo:src/bar/ /data/tmp

       A trailing slash on the source changes this behavior to avoid creating
       an additional directory level at the destination.  You can think of a
       trailing / on a source as meaning "copy the contents of this directory"
       as opposed to "copy the directory by name", but in both cases the
       attributes of the containing directory are transferred to the
       containing directory on the destination.  In other words, each of the
       following commands copies the files in the same way, including their
       setting of the attributes of /dest/foo:

              rsync -av /src/foo /dest
              rsync -av /src/foo/ /dest/foo



Thanks: 24
Messages: 44

The same logic applies to cp as well, when invoked recursively (with the -R option). Without trailing slash, given directories are copied including their contents. With trailing slash, cp only copies the contents of given directories.