[LINUX] rsync Behavior changes depending on the presence or absence of the slash in the copy source

Basic syntax

rsync [options] [source] [destination]

Points to remember

--Behavior differs depending on the presence or absence of the trailing slash in the copy source --It doesn't matter if the copy destination has a trailing slash.

If you want to synchronize the directory body

$ rsync -av /src/a /bkup
$ rsync -av /src/a /bkup/
#The above has the same meaning

--The main body of directory a is copied directly under / bkup. --If you put / at the end of the copy source, the contents of directory a will be placed directly under / bkup, so there will be no a folder in the copy destination.

If you want to synchronize the contents of the directory

$ rsync -av /src/a/ /bkup/a
$ rsync -av /src/a/ /bkup/a/
#The above has the same meaning

--The contents of directory a are copied directly under / bkup / a. --If you delete / at the end of the copy source, the directory a itself will be placed directly under / bkup / a, resulting in / bkup / a / a.

Reference article

https://qiita.com/QUANON/items/2953c52df7f65f2ecee5 http://code.lioon.net/shell/how-to-set-paths-for-rsync.html https://www.itmedia.co.jp/enterprise/articles/0804/21/news013.html

Pointed out

https://www.kabegiwablog.com/entry/2018/06/21/100000

This article says the exact opposite. ..

Recommended Posts

rsync Behavior changes depending on the presence or absence of the slash in the copy source
How the reference of the python array changes depending on the presence or absence of subscripts
In Python, change the behavior of the method depending on how it is called
Difference in results depending on the argument of multiprocess.Process
A note on the default behavior of collate_fn in PyTorch
Predict the presence or absence of infidelity by machine learning
Behavior when Linux less ends depending on the connection source
[Jinja2] Changes in line breaks depending on the hyphen position
Confirmed the difference in the presence or absence of random processing during mini-batch learning with chainer
Check the behavior of destructor in Python
[Linux] Difference in time information depending on the clock ID of the clock_gettime () function
I tried to predict the presence or absence of snow by machine learning.
About the behavior of copy, deepcopy and numpy.copy
The behavior of signal () depends on the compile options
Make a copy of the list in Python
About the behavior of Model.get_or_create () of peewee in Python
Slightly different behavior depending on version in Pandas
The return value of len or unichr may change depending on whether it is UCS-2 or UCS-4.
Source code of "Set the color on the poster side so that the color of Youtube subtitles changes automatically."