Lesson 4 EXIT program control and expression flow control

Lesson 4 EXIT program control and expression flow control

[root@node1 ~]# ls a.txt
ls: cannot access a.txt: No such file or directory
[root@node1 ~]# echo $?
2
[root@node1 ~]# ls /root/
anaconda-ks.cfg break2.sh break.sh cont1.sh continue.sh nginx-1.6.0.tar.gz
[root@node1 ~]# echo $?
0

exit status
Exit status code:
0 Command completed successfully
1 Usual unknown error
2 Misuse of shell command
126 Command cannot be executed
127 Command not found
128 Invalid exit parameter
128+x Fatal error using Linux signal x.
130 Command terminated with Ctrl-C
255 Exit status outside the specification

status is represented by a number between 0-255, and the return status value is accompanied by the exit of the script (in fact, exit).
The value of $? can be queried using echo

Status code error message
222 Null character
211

status is represented by a number between 0-255, and the return status value is accompanied by the exit of the script (in fact, exit).
The value of $? can be queried using echo

Guess you like

Origin blog.csdn.net/weixin_45603370/article/details/110919277