echo $?
root@xxx:~/test# pwd
/root/test
root@xxx:~/test# echo $?
0
root@xxx:~/test# error_command
error_command:未找到命令
root@xxx:~/test# echo $?
127
从上面可以看到,当命令pwd正常运行后,可以得到一个正确的返回值0,而输入一个不存在的命令后,则返回码为127,表示错误
echo $?
root@xxx:~/test# pwd
/root/test
root@xxx:~/test# echo $?
0
root@xxx:~/test# error_command
error_command:未找到命令
root@xxx:~/test# echo $?
127
从上面可以看到,当命令pwd正常运行后,可以得到一个正确的返回值0,而输入一个不存在的命令后,则返回码为127,表示错误