bash - rysnc 排除目录不起作用
问题描述
我有一个运行到 rsync 的脚本。我设置了 --exclude 但它忽略并同步这些文件夹。
set -x;
cd $(dir_name $0);
dest="/home/pi/bash_scripts_2/"
export RSYNC_RSH="ssh -q";
#excluding html and man folders
for dir in html man; do
rsync -hav ./$dir/ --exclude 'html/' ./$dir/ $dest$dir/;
rsync -hav ./$dir/ --exclude 'man/' ./$dir/ $dest$dir/;
done
解决方案
您的循环正在做四件事。
第一个循环:
rsync html/ to dest/html excluding html/ (nothing copied)
rsync html/ to dest/html excluding man/ (html is copied to dest/html)
第二个循环:
rsync man/ to dest/man excluding html/ (man is copied to dest/man)
rsync man/ to dest/man excluding man/ (nothing copied)
所以总的来说,你正在复制这两个文件夹。
推荐阅读
- ios - ObservableObject 正在更新所有视图并导致 SwiftUI 中的菜单关闭
- php - 为什么 DateTimeZone :: listAbbreviations() 和 DateTimeZone :: listIdentifiers () 之间存在不同的时区
- r - 根据条件使一些样本名称唯一
- c# - Cosmos DB 加快读取速度
- javascript - Uncaught UnknownError:无法在“MediaRecorder”上执行“start”:启动 MediaRecorder 时出错
- azure-devops - 从测试计划运行自动化测试给出错误未找到测试源
- sql - 使用项目值作为选择代码的一部分
- django - django-datatable-view==0.9.0 Django 3.1.3:ImportError:无法导入名称'FieldDoesNotExist'
- vue.js - 刷新后如何使vue导航守卫工作
- reactjs - ReactJS 中 useEffect() 中的增量值