Unix中的错误(脚本)

时间:2010-06-02 13:01:22

标签: unix scripting csh tcsh

有人知道这个错误是什么意思吗? 谷歌Missing -.我发现了这个

1 个答案:

答案 0 :(得分:2)

tcsh可以产生该错误消息的唯一情况是,当您尝试替换数组变量中的一系列单词时,选择器在语法上是不正确的。

引用tcsh手册页:

   $name[selector]
   ${name[selector]}
           Substitutes  only  the  selected  words from the value of name.
           The selector is subjected to `$' substitution and  may  consist
           of  a  single  number  or  two numbers separated by a `-'.  The
           first word of a variable's value is numbered `1'.  If the first
           number  of  a range is omitted it defaults to `1'.  If the last
           member of a range is omitted  it  defaults  to  `$#name'.   The
           selector `*' selects all words.  It is not an error for a range
           to be empty if the second argument is omitted or in range.

例如:

$ echo $path[5-6]
/usr/sbin /usr/bin
$ echo $path[5_6]
Missing -.

也许如果您在被要求提供更多信息时(例如,来自失败脚本的一些代码)进行了跟进,那么获得答案将花费一年多的时间。