【问题标题】:Sh script what does `$?`?sh 脚本 `$?` 是什么?
【发布时间】:2017-03-18 18:56:35
【问题描述】:

我想知道$?的功能?

例如,如果一个变量有这个值,比如VARIABLE=$?

如果是运算符,当然有办法知道这种运算符。

【问题讨论】:

  • 最后一个命令返回码。
  • 您的问题是关于“$”还是“$?” ?因为标题不适合摘要编辑
  • @F4240 $? 在原始问题中包含在**...** 中,清楚地表明问题是关于那个特定的特殊参数。
  • @chepner,真的,我不明白这个问题是关于$?,而不是$,很抱歉造成混淆。

标签: bash sh


【解决方案1】:

$?给你最后的返回码

【讨论】:

    【解决方案2】:
    $#    Stores the number of command-line arguments that 
          were passed to the shell program.
    $?    Stores the exit value of the last command that was 
          executed.
    $0    Stores the first word of the entered command (the 
          name of the shell program).
    $*    Stores all the arguments that were entered on the
          command line ($1 $2 ...).
    "$@"  Stores all the arguments that were entered
          on the command line, individually quoted ("$1" "$2" ...).
    

    【讨论】:

    猜你喜欢
    • 2011-12-12
    • 2012-02-24
    • 2012-02-05
    • 2011-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-28
    相关资源
    最近更新 更多