ubuntu退出shell终端命令_Linux命令之exit - 退出当前shell【返回值状态】

用途说明

exit命令用于退出当前shell,在shell脚本中可以终止当前脚本执行。

常用参数

格式:exit n

退出。设置退出码为n。(Cause the shell to exit with a status of n.)

格式:exit

退出。退出码不变,即为最后一个命令的退出码。(If n is omitted, the exit status is that of the  last  command executed. )

格式:$?

上一个命令的退出码。

格式:trap "commands" EXIT

退出时执行commands指定的命令。( A trap on EXIT is executed before the shell terminates.)

退出码(exit status,或exit code)的约定:

0表示成功(Zero - Success)

非0表示失败(Non-Zero  - Failure)

2表示用法不当(Incorrect Usage)

127表示命令没有找到(Command Not Found)

126表示不是可执行的(Not an executable)

>=128 信号产生

man 3 exit 写道

The C standard specifies two constants, EXIT_SUCCESS and EXIT_FAILURE, that may be passed to exit() to indicate        successful or unsuccessful termination, respectively.

以下摘自/u

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值