【问题标题】:bash: syntax error near unexpected tokenbash:意外标记附近的语法错误
【发布时间】:2011-10-30 04:01:50
【问题描述】:

我在 .bashrc 中有这个别名:

alias clone='while ! rsync --rsh=ssh -avP --delete --stats --compress-level=9 $1/ $2:$3 | grep -q "Number of files transferred: 0" ; do echo -n .; sleep 1; done'

执行此操作时出错:

clone /d/root/tmp cowboy@hicow.com /temp
bash: syntax error near unexpected token `/d/root/tmp'

如果我把它放在脚本文件中,一切都会正常:

#!/bin/sh
while ! rsync --rsh=ssh -avP --delete --stats --compress-level=9 $1/ $2:$3 | grep -q "Number of files transferred: 0" ; do echo -n .; sleep 1; done

并像这样执行脚本文件:

./clonescript /d/root/tmp cowboy@hicow.com /temp

非常感谢任何帮助。

【问题讨论】:

    标签: bash shell syntax


    【解决方案1】:

    别名没有位置参数。而是创建一个函数。

    clone() {
      while ...
       ...
    }
    

    【讨论】:

      猜你喜欢
      • 2014-02-26
      • 2018-12-18
      • 2014-01-20
      • 2015-12-11
      • 2021-07-29
      • 2014-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多