rsync exclude 困惑

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
百草谷居士
帖子: 3930
注册时间: 2006-02-10 16:36
系统: Mint21.1/Deepin20.8

rsync exclude 困惑

#1

帖子 百草谷居士 » 2023-04-07 8:41

在使用 rsync 同步文件时,使用 --exclude 或者 --exclude-from=filelist 时,有些困惑
1、如果想排除一级文件夹 xyz ,但是不排除名为 xyz 的子文件夹时,应该如何指定?
2、Windows回收站文件夹 $RECYCLE.BIN ,如何指定?我直接把这个文件夹名写到 excludefilelist 中后,反而会自动建立这个文件夹,搞得这个文件夹到处都是。
debian 12 / 深度系统 20.9 / Mint 21.3

为何热衷于搞发行版的多,搞应用程序开发的少?Linux最多余的就是各种发行版,最缺的就是应用程序,特别是行业应用程序。
头像
astolia
论坛版主
帖子: 6486
注册时间: 2008-09-18 13:11

Re: rsync exclude 困惑

#2

帖子 astolia » 2023-04-07 10:07

有空去花时间读一下manpage中的描述,就不用当伸手党了

代码: 全选

$ find
.
./c
./c/b
./b
$ rsync -av --exclude='/b' . /tmp/x
sending incremental file list
created directory /tmp/x
./
c/
c/b/

sent 117 bytes  received 56 bytes  346.00 bytes/sec
total size is 0  speedup is 0.00

$ find
.
./a.txt
./$RECYCLE.BIN
$ cat a.txt
$RECYCLE.BIN
$ rsync -av --exclude-from=a.txt . /tmp/y
sending incremental file list
created directory /tmp/y
./
a.txt

sent 146 bytes  received 67 bytes  426.00 bytes/sec
total size is 13  speedup is 0.06
$ rsync -av --exclude='$RECYCLE.BIN' . /tmp/z
sending incremental file list
created directory /tmp/z
./
a.txt

sent 146 bytes  received 67 bytes  426.00 bytes/sec
total size is 13  speedup is 0.06
头像
百草谷居士
帖子: 3930
注册时间: 2006-02-10 16:36
系统: Mint21.1/Deepin20.8

Re: rsync exclude 困惑

#3

帖子 百草谷居士 » 2023-04-10 13:09

我测试测试
debian 12 / 深度系统 20.9 / Mint 21.3

为何热衷于搞发行版的多,搞应用程序开发的少?Linux最多余的就是各种发行版,最缺的就是应用程序,特别是行业应用程序。
回复