【问题标题】:error in Unix (scripts)Unix 中的错误(脚本)
【发布时间】:2010-06-02 13:01:21
【问题描述】:

有人知道这个错误是什么意思吗? Missing -. 在 google 中我没有发现任何关于此的信息

【问题讨论】:

  • 我使用的是C-Shell,我写了一些脚本,但是因为出现这个错误而无法运行
  • 这里有心灵感应的人很少。你能发布你的脚本清单吗?
  • 您还有兴趣解决这个问题吗?

标签: unix scripting csh tcsh


【解决方案1】:

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 -.

如果您在被要求提供更多信息(例如,失败脚本中的一些代码)时跟进,可能不会花费一年多的时间来获得答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-22
    • 1970-01-01
    • 2017-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-09
    相关资源
    最近更新 更多