• 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: 5
Messages: 74


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: 419
Messages: 1,210

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: 288
Messages: 768

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: 19
Messages: 28

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.