什么是$?在 bash 中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22280653/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is $? in bash?
提问by Baruch
I am trying to understand a script that was written a few years ago by someone that is no longer available here. The script references $?
a few times. What is this?
我试图理解几年前由这里不再可用的人编写的脚本。该脚本引用$?
了几次。这是什么?
P.S. Google couldn't help since it seems to strip the $?
from the search term
PS Google 无能为力,因为它似乎$?
从搜索词中删除了
回答by Basile Starynkevitch
You really should read the GNU bashmanual. $?
is a special parameterwhich
你真的应该阅读GNU bash手册。$?
是一种特殊的参数,其
expands to the exit status of the most recently executed foreground pipeline.
扩展到最近执行的前台管道的退出状态。
Read also the advanced bash scripting guide.
另请阅读高级 bash 脚本指南。