BASH Rsync排除不起作用。语法可能出错?

时间:2013-07-27 06:01:21

标签: linux bash syntax terminal rsync

我正在尝试从终端运行以下代码行,并且rysnc正常工作,但是,正如相关控制台输出所示,它不会排除我想要的文件。我的语法中有什么问题吗?

输入命令:

rsync -va --exclude="Frisnuk/((plugins/dynmap.*)|(orebfuscator_cache.*))" --force Frisnuk .backups/07.25.2013-13:05/MinecraftServer/Frisnuk

控制台输出:

...
Frisnuk/orebfuscator_cache/
Frisnuk/orebfuscator_cache/Frisnuk/
Frisnuk/orebfuscator_cache/Frisnuk/data/
Frisnuk/orebfuscator_cache/Frisnuk/data/region/
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.-1.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.-10.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.-2.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.-3.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.-4.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.-5.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.-6.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.-7.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.-8.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.-9.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.0.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.1.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.2.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.3.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.4.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-1.5.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.-1.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.-10.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.-2.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.-3.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.-4.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.-5.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.-6.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.-7.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.-9.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.0.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.1.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.2.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.3.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.4.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-2.5.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-3.-1.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-3.-10.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-3.-2.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-3.-3.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-3.-4.mcr
Frisnuk/orebfuscator_cache/Frisnuk/data/region/r.-3.-5.mcr
...

修改 正如rsync --exclude not excluding specific files所建议的那样,我相对于来源做了排除,但也失败了:

rsync -va --exclude="((plugins/dynmap.*)|(orebfuscator_cache.*))" --force Frisnuk .backups/07.27.2013-02:30/MinecraftServer/Frisnuk

1 个答案:

答案 0 :(得分:3)

rsync过滤规则不是非正则表达式,请尝试:

rsync -va --exclude='Frisnuk/plugins/dynmap/**' --exclude='Frisnuk/orebfuscator_cache/**'  ...