含义$的?在shell脚本 [英] Meaning of $? in shell scripts

查看:213
本文介绍了含义$的?在shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是什么

echo $?

在bash编程呢?

推荐答案

这是最后执行的命令的退出状态。

This is the exit status of the last executed command.

例如命令真正总是返回的状态 0 总是返回的状态 1

For example the command true always returns a status of 0 and false always returns a status of 1:

true
echo $? # echoes 0
false
echo $? # echoes 1

这本手册:(通过调用男人庆典在你的shell acessible)

From the manual: (acessible by calling man bash in your shell)

$?扩展为最近执行的前台管道的退出状态。

$?       Expands to the exit status of the most recently executed foreground pipeline.

按照惯例 0 的退出状态就意味着成功和非零返回状态意味着失败。了解更多关于的退出状态维基百科

By convention an exit status of 0 means success, and non-zero return status means failure. Learn more about exit statuses on wikipedia.

有这样的其他特殊变量,你可以在这个在线手册看到:<一href=\"https://www.gnu.org/s/bash/manual/bash.html#Special-Parameters\">https://www.gnu.org/s/bash/manual/bash.html#Special-Parameters

There are other special variables like this, as you can see on this online manual: https://www.gnu.org/s/bash/manual/bash.html#Special-Parameters

这篇关于含义$的?在shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆