4-10.5 Linux 中的文件同步传输 --- rsync 源目录有 / 和 没有 / 区别

  • 源目录有 / 和 没有 / 区别。源目录后带 / 号是指对目录下的文件进行传输,没有带 / 号是指连同目录以及目录下的文件一并传输。新建 backups_directory 目录用作储存源目录,新建 backups_file 目录储存源目录的文件。
[root@localhost test]# mkdir backups_directory    ## backups_directory 目录用作储存源目录
[root@localhost test]# 
[root@localhost test]# mkdir backups_file    ## backups_file 目录储存源目录的文件
[root@localhost test]# 
[root@localhost test]# tree    ## 查看目录结构
.
├── backups_directory
├── backups_file
└── SRC
    ├── demo1.txt
    ├── demo2.txt
    └── demo3.txt

3 directories, 3 files

## SRC 目录后没有带 / 号,是整个 SRC目录递归传输到 backups_directory 目录下
[root@localhost test]# rsync -a SRC backups_directory/    

## SRC 目录后带 / 号,是 SRC目录下的文件传输到 backups_file 目录下
[root@localhost test]# rsync -a SRC/ backups_file/
[root@localhost test]# 
[root@localhost test]# tree    ## 目录结构如下
.
├── backups_directory
│   └── SRC
│       ├── demo1.txt
│       ├── demo2.txt
│       └── demo3.txt
├── backups_file
│   ├── demo1.txt
│   ├── demo2.txt
│   └── demo3.txt
└── SRC
    ├── demo1.txt
    ├── demo2.txt
    └── demo3.txt

4 directories, 9 files
[root@localhost test]# 

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容