2013-04-10 70 views
1

我试图让这个脚本的工作,但我失去了一些东西..Rsync的和动态排除

exclude="" 
while read line 
do 
    exclude+="--exclude $line " 
done < exclude.ini 
echo "$exclude" 
"rsync -rvi --delete $exclude /var/www/$1 /var/export" 

该脚本读取需要从文件中排除的文件,但我米不能正确串接那些字符串

文件中的条目是这样写的 的.svn _svn 的.htaccess ReadAndDeleteMe.ini 缓存/ * 文档

任何人都可以帮忙吗?

+0

什么'回声 “$排除”'打印?另外如果你有通配符可能会导致扩展问题。最后我认为最后一行应该是'eval“rsync ....”'这样表达式就被评估了。 – James 2013-04-10 16:27:58

+0

它打印从文件中提取的文本的一部分..我仍然需要通过@enzotib来测试提供的解决方案,但我想这可能是我正在寻找的解决方案。手册页始终有助于最终:-) – Easly 2013-04-10 21:53:21

回答

1

我会用

--exclude-from=exclude.ini 

其实手册页说:

--exclude-from=FILE 
      This option is related to the --exclude option, but it specifies 
      a FILE that contains exclude patterns (one per line). Blank 
      lines in the file and lines starting with ’;’ or ’#’ are 
      ignored. If FILE is -, the list will be read from standard 
      input. 
+0

明天我会尝试报告,谢谢! – Easly 2013-04-10 21:50:43

+0

它的工作原理,谢谢:) – Easly 2013-04-12 08:59:03