2013-04-10 48 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