【问题标题】:Rsync and dynamic excludeRsync 和动态排除
【发布时间】:2013-04-10 16:21:24
【问题描述】:

我正在尝试使这个小脚本工作,但我错过了一些东西..

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 缓存/* 文档

有人可以帮忙吗?

【问题讨论】:

  • echo "$exclude" 打印什么?此外,如果您在其中有可能导致 shell 扩展问题的通配符。最后我认为最后一行应该是eval "rsync....",所以表达式被评估了。
  • 它打印从文件中获取的部分文本。我仍然需要测试@enzotib 提供的解决方案,但我想它可能是我正在寻找的解决方案。手册页总是有帮助最后:-)

标签: bash shell loops rsync


【解决方案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.

【讨论】:

    猜你喜欢
    • 2013-01-09
    • 2015-06-11
    • 2018-08-29
    • 2018-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-17
    • 1970-01-01
    相关资源
    最近更新 更多