Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我遇到了以下命令:
echo $?
该命令有什么作用?
回显(打印)上一个命令的退出值。
如果失败,它将不同于零 ( 0)。
0
$ cd ~ $ echo $? > 0 $ cd //whatever/ > bash: cd: //whatever/: No such file or directory $ echo $? > 1
程序以状态码退出。每个程序都是独一无二的,并且有一组不同的失败代码,但公认的0是“成功”代码。