• 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

TomHsiung

Member

Thanks: 4
Messages: 95

#1
Hello,

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

Please compare

Code:
rsync -Phr "/Volumes/Data/StarCraft II" admin@192.168.1.230:/data/Softwares/games/starcraft_2/
with

Code:
rsync -Phr "/Volumes/Data/StarCraft II/" admin@192.168.1.230:/data/Softwares/games/starcraft_2/
Some one know the difference between /xxx/xxx/path and /xxx/xxx/path/? What difference does the final / make?

Much appreciated!
 

usdmatt

Daemon

Thanks: 452
Messages: 1,275

#2
Code:
rsync /source/ /dest/
This will sync the files in the source directory into dest

Code:
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.
 

aragats

Aspiring Daemon

Thanks: 347
Messages: 871

#3
from rsync(1):
Code:
....
              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
....
 

p3rj

Member

Thanks: 24
Messages: 44

#4
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.
 
Top