Why add a trailing slash after an rsync destination?
Clash Royale CLAN TAG#URR8PPP
up vote
8
down vote
favorite
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 dir1..3
$ touch dir1/file
$ rsync -r dir1/ dir2
$ rsync -r dir1/ dir3/
$ ls dir*
dir1:
file
dir2:
file
dir3:
file
Does appending a '/' to the destination actually have a use sometimes?
rsync
add a comment |Â
up vote
8
down vote
favorite
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 dir1..3
$ touch dir1/file
$ rsync -r dir1/ dir2
$ rsync -r dir1/ dir3/
$ ls dir*
dir1:
file
dir2:
file
dir3:
file
Does appending a '/' to the destination actually have a use sometimes?
rsync
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 '17 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."
â Hauke Laging
Nov 4 '17 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 didrsync -r dir1/subdir1 dir2/
it will copy the contents ofsubdir1
intodir2
but if you didrsync -r dir1/subdir1/ dir2/
it will copy the whole directory (including contents)subdir1
intodir2
so you would have./dir2/subdir1/
â Jesse_b
Nov 4 '17 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.
â Hauke Laging
Nov 4 '17 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 '17 at 22:33
add a comment |Â
up vote
8
down vote
favorite
up vote
8
down vote
favorite
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 dir1..3
$ touch dir1/file
$ rsync -r dir1/ dir2
$ rsync -r dir1/ dir3/
$ ls dir*
dir1:
file
dir2:
file
dir3:
file
Does appending a '/' to the destination actually have a use sometimes?
rsync
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 dir1..3
$ touch dir1/file
$ rsync -r dir1/ dir2
$ rsync -r dir1/ dir3/
$ ls dir*
dir1:
file
dir2:
file
dir3:
file
Does appending a '/' to the destination actually have a use sometimes?
rsync
asked Nov 4 '17 at 21:57
EmmaV
9891028
9891028
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 '17 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."
â Hauke Laging
Nov 4 '17 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 didrsync -r dir1/subdir1 dir2/
it will copy the contents ofsubdir1
intodir2
but if you didrsync -r dir1/subdir1/ dir2/
it will copy the whole directory (including contents)subdir1
intodir2
so you would have./dir2/subdir1/
â Jesse_b
Nov 4 '17 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.
â Hauke Laging
Nov 4 '17 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 '17 at 22:33
add a comment |Â
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 '17 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."
â Hauke Laging
Nov 4 '17 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 didrsync -r dir1/subdir1 dir2/
it will copy the contents ofsubdir1
intodir2
but if you didrsync -r dir1/subdir1/ dir2/
it will copy the whole directory (including contents)subdir1
intodir2
so you would have./dir2/subdir1/
â Jesse_b
Nov 4 '17 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.
â Hauke Laging
Nov 4 '17 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 '17 at 22:33
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 '17 at 22:05
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 '17 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."
â Hauke Laging
Nov 4 '17 at 22:10
@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."
â Hauke Laging
Nov 4 '17 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 '17 at 22:15
@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 '17 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.
â Hauke Laging
Nov 4 '17 at 22:32
@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.
â Hauke Laging
Nov 4 '17 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 '17 at 22:33
@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 '17 at 22:33
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
19
down vote
accepted
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 offile
inside a directorydest
, whereas$ rsync file dest
will make a copy of the filefile
calleddest
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 >
Thank you. So if directorydest
already exists, there's no need for the trailing slash?
â EmmaV
Nov 4 '17 at 22:16
Exactly. If in the example above a directorydest
exists, a copy offile
will be created inside in both cases.
â resc
Nov 4 '17 at 22:20
This was the clearest answer I could follow (being a newbie :-). Thanks +1
â beeshyams
Jun 30 at 15:06
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
19
down vote
accepted
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 offile
inside a directorydest
, whereas$ rsync file dest
will make a copy of the filefile
calleddest
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 >
Thank you. So if directorydest
already exists, there's no need for the trailing slash?
â EmmaV
Nov 4 '17 at 22:16
Exactly. If in the example above a directorydest
exists, a copy offile
will be created inside in both cases.
â resc
Nov 4 '17 at 22:20
This was the clearest answer I could follow (being a newbie :-). Thanks +1
â beeshyams
Jun 30 at 15:06
add a comment |Â
up vote
19
down vote
accepted
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 offile
inside a directorydest
, whereas$ rsync file dest
will make a copy of the filefile
calleddest
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 >
Thank you. So if directorydest
already exists, there's no need for the trailing slash?
â EmmaV
Nov 4 '17 at 22:16
Exactly. If in the example above a directorydest
exists, a copy offile
will be created inside in both cases.
â resc
Nov 4 '17 at 22:20
This was the clearest answer I could follow (being a newbie :-). Thanks +1
â beeshyams
Jun 30 at 15:06
add a comment |Â
up vote
19
down vote
accepted
up vote
19
down vote
accepted
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 offile
inside a directorydest
, whereas$ rsync file dest
will make a copy of the filefile
calleddest
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 >
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 offile
inside a directorydest
, whereas$ rsync file dest
will make a copy of the filefile
calleddest
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 >
edited Nov 4 '17 at 22:29
answered Nov 4 '17 at 22:10
resc
827315
827315
Thank you. So if directorydest
already exists, there's no need for the trailing slash?
â EmmaV
Nov 4 '17 at 22:16
Exactly. If in the example above a directorydest
exists, a copy offile
will be created inside in both cases.
â resc
Nov 4 '17 at 22:20
This was the clearest answer I could follow (being a newbie :-). Thanks +1
â beeshyams
Jun 30 at 15:06
add a comment |Â
Thank you. So if directorydest
already exists, there's no need for the trailing slash?
â EmmaV
Nov 4 '17 at 22:16
Exactly. If in the example above a directorydest
exists, a copy offile
will be created inside in both cases.
â resc
Nov 4 '17 at 22:20
This was the clearest answer I could follow (being a newbie :-). Thanks +1
â beeshyams
Jun 30 at 15:06
Thank you. So if directory
dest
already exists, there's no need for the trailing slash?â EmmaV
Nov 4 '17 at 22:16
Thank you. So if directory
dest
already exists, there's no need for the trailing slash?â EmmaV
Nov 4 '17 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 '17 at 22:20
Exactly. If in the example above a directory
dest
exists, a copy of file
will be created inside in both cases.â resc
Nov 4 '17 at 22:20
This was the clearest answer I could follow (being a newbie :-). Thanks +1
â beeshyams
Jun 30 at 15:06
This was the clearest answer I could follow (being a newbie :-). Thanks +1
â beeshyams
Jun 30 at 15:06
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f402555%2fwhy-add-a-trailing-slash-after-an-rsync-destination%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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 '17 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."
â Hauke Laging
Nov 4 '17 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 ofsubdir1
intodir2
but if you didrsync -r dir1/subdir1/ dir2/
it will copy the whole directory (including contents)subdir1
intodir2
so you would have./dir2/subdir1/
â Jesse_b
Nov 4 '17 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.
â Hauke Laging
Nov 4 '17 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 '17 at 22:33