我一直在用我认为简单的rsync
命令行来解决一些我不理解的事情。
rsync -u -v -r -n "~/usb/.notes/_tech" "~/.notes/_tech"
其中:usb
节点是(已知)usb的挂载点。问题是以下两种变化会产生截然不同的结果。
示例1 。
$ rsync -u -v -r -n "~/usb/.notes/_tech" "~/.notes/_tech" | tee | wc -l
:
sent 94,378 bytes received 6,340 bytes 201,436.00 bytes/sec
total size is 13,222,770,177 speedup is 131,285.07 (DRY RUN)
示例2 。
$ rsync -u -v -r -n "~/usb/.notes/_tech/" "~/.notes/_tech/" | tee | wc -l
:
sent 88,352 bytes received 334 bytes 177,372.00 bytes/sec
total size is 13,222,770,177 speedup is 149,096.48 (DRY RUN)
T 因此 ...我想例子#1给了我那棵树上的所有文件。虽然,例子#2更多 - 正如我预期的那样(但并不意味着'正确')。
问题 :
ls -lt**c**
命令时我需要使用rsync
。 (一旦你意识到这一点就很明显了。)rsync
时,“尺寸确实重要”。dir/
”与“dir
”(无斜线)的语义差异。我无法看到如果有一个递归开关(-r
)有多少差异。我没有在示例中看到结构问题;所以我从stackoverflow中寻求智慧?!!见解?
智慧寻求。
答案 0 :(得分:4)
所有问题的答案都在手册页中:
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.
因此rsync -r /foo/ /tmp
会将/foo
中的所有内容放入/tmp
,而rsync -r /foo /tmp
会将/foo
中的所有内容放入/tmp/foo
。