linux命令后添加 exit 0什么意思

例如这个命令
Test –z $filename && echo “you must input a file” && exit 0
后面的 && exit 0 是什么意思

使脚本返回码为0,表示成功

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个回答  2018-03-02
&&表示如果前面的命令成功执行则继续后面的命令,exit退出当前shell并且返回0,0这个返回值表示命令成功执行
第2个回答  2015-07-03
exit 0:输出0一般表示命令执行正确没有错误,一般会在shell脚本里面设置大于0的数字表示错误信息。本回答被网友采纳
第3个回答  2010-04-22
如果前面执行成功的话,以0值为返回值退出。本回答被提问者采纳
第4个回答  2015-05-24
代表命令正确执行,操作系统的返回值为0

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网