当前位置:网站首页>bash shell中的退出状态码
bash shell中的退出状态码
2022-04-21 10:17:00 【Alfred.HOO】
shell中运行的每个命令都使用退出状态码告诉shell它已经运行完毕。提出状态码是一个0-255的整数值,在命令结束运行时有命令传给shell。可以捕获这个值并在脚本中使用。
Linux提供了一个专门的变量 ? 来 保 存 上 个 已 执 行 命 令 的 退 出 状 态 码 。 对 于 需 要 进 行 检 查 的 命 令 , 必 须 在 其 运 行 完 毕 后 立 刻 查 看 或 使 用 ?来保存上个已执行命令的退出状态码。对于需要进行检查的命令,必须在其运行完毕后立刻查看或使用 ?来保存上个已执行命令的退出状态码。对于需要进行检查的命令,必须在其运行完毕后立刻查看或使用?变量。它的值会变成由shell所执行的最后一条命令的退出状态码。
date
echo $?
按照惯例,一个成功结束的命令的退出状态码是0。如果一个命令结束时有错误,退出状态码就是一个正数值。
| 状态码 | 描述 |
|---|---|
| 0 | 命令成功结束 |
| 1 | 一般性未知错误 |
| 2 | 不适合的shell命令 |
| 126 | 命令不可执行 |
| 127 | 没找到命令 |
| 128 | 无效的退出参数 |
| 128+x | 与Linux信号x相关的严重错误 |
| 130 | 通过Ctrl+C终止的命令 |
| 255 | 正常范围之外的退出状态码 |
版权声明
本文为[Alfred.HOO]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Michael177/article/details/124306281
边栏推荐
猜你喜欢

Jeecgboot: the difference between online form control drop-down box and drop-down search box

Exon bed file acquisition
![[hand in hand to prepare you for the electric game] use the timer interrupt to change the PWM duty cycle](/img/b3/203fdbd700347c531e6567b6972594.png)
[hand in hand to prepare you for the electric game] use the timer interrupt to change the PWM duty cycle

ArUco与OpenCV

Daily question (2022-04-20) - the longest absolute path of the file

Fudan University - University of Washington EMBA Alumni: Turning "her power" into "our power"

管道通信
![[daily question 1] stone jumping -- dynamic programming](/img/c2/ae0cd99aedf41a62a41d07591d9a55.png)
[daily question 1] stone jumping -- dynamic programming

C#入门-并行编程

搭建个人主页保姆级教程(一)
随机推荐
Using pycharm to load the QRC resource file in pyside2
M3u8 Video Downloader IDM breaks through the failure to download protected data and cannot be restricted
Mapbox 创建多个可拖动的标记点
C#入门-利用正则表达式校验身份证号
2022信息与未来预备刷题2《New Online Judge 1113: 位数问题》
Promise处理复杂异步
【无标题】定时的
Nanny level tutorial on building personal home page (I)
-bash: /home/lylg/bin/kf.sh: /bin/bash^M: bad interpreter: No such file or directory
CANoe:Vector Tool Platform是什么
网站被挂博彩暗链
[pytorch] Monai vit network graphic analysis
【无标题】
One trick is to solve the servlet of servlet [dispatcher servlet] Init() threw an exception
JS初练——弹弹球与墙壁碰撞处理实例
gltf模型带透明贴图的显示问题
Common commands of MySQL in Linux
自动化运维平台未来的发展前景?
Read the meaning of seek tiger's launch of Genesis node
Ant a-table tree table cascade selection