首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

小弟我使用过的Linux命令之exit - 退出当前shell

2012-07-15 
我使用过的Linux命令之exit - 退出当前shell我使用过的Linux命令之exit - 退出当前shell本文链接:http://c

我使用过的Linux命令之exit - 退出当前shell
我使用过的Linux命令之exit - 退出当前shell

本文链接:http://codingstandards.iteye.com/blog/836625 ? (转载请注明出处)

?

用途说明

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 信号产生

?

?

示例四 在脚本中,退出时删除临时文件

?

示例五 检查上一命令的退出码
?问题思考相关资料

【1】91linux??? Linux exit 命令???
【2】曲径通幽?? [概念]exit n???
【3】Linux大学? Bash Shell Exit Status Tutorial with Practical Examples??

?

返回 我使用过的Linux命令系列总目录

?

热点排行