rsync源目录写法的一点小细节

原始状态:

[root@localhost tmp]# tree

.

├── a

│   ├── a1

│   └── a2

└── b

 

2 directories, 2 files

 

[root@localhost tmp]# rsync -av --progress a b

sending incremental file list

a/

a/a1

           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=1/3)

a/a2

           0 100%    0.00kB/s    0:00:00 (xfer#2, to-check=0/3)

 

sent 143 bytes  received 54 bytes  394.00 bytes/sec

 

[root@localhost tmp]# tree

.

├── a

│   ├── a1

│   └── a2

└── b

    └── a

        ├── a1

        └── a2

 

 

 

回到原始状态:

注意,源目录多了一个斜杆:

[root@localhost tmp]# rsync -av --progress a/ b

sending incremental file list

./

a1

           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=1/3)

a2

           0 100%    0.00kB/s    0:00:00 (xfer#2, to-check=0/3)

 

sent 133 bytes  received 53 bytes  372.00 bytes/sec

total size is 0  speedup is 0.00

[root@localhost tmp]# tree

.

├── a

│   ├── a1

│   └── a2

└── b

    ├── a1

    └── a2

 

2 directories, 4 files

 

 

变成了a下面的内容复制到文件b下,而不是像第一次的包括a整个目录

目标如果是文件夹的话,最后有没有加斜杆都不影响。

加-n参数可以进行dry-run模式,即只显示有可能的改变,但实际并不执行。

 

posted @ 2018-02-07 20:40  泽锦  阅读(386)  评论(0编辑  收藏  举报