什么时候在目录中添加“/”会改变其含义?

什么时候在目录中添加“/”会改变其含义?

/添加到目录什么时候会改变其含义?

例如,Linux 简述:

将整个目录 proj 传输到远程主机 ourhub 上的 /planning 目录:

$ rsync -r proj/ ourhub:/planning

将 proj 下的文件和子目录传输到远程主机 ourhub 上的 /planning 目录:

$ rsync -r proj ourhub:/planning

ls projls proj/是一样的。 (我想我以前问过类似的问题,但我找不到)。谢谢。

答案1

没有系统范围内的规则;但是,您看到的行为rsync记录在 rsync 手册页的开头附近:

          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:

相关内容