root@localhost:~# ls /usr/bin/share ls: cannot access /usr/bin/share: No such file or directory root@localhost:~# echo $? 2 如果结束状态不是0,说明命令执行失败。
Q:7 在shell脚本中如何比较两个数字 ? 答:在if-then中使用测试命令( -gt 等)来比较两个数字,例子如下: #!/bin/bash x=10 y=20 if [ $x -gt $y ] then echo “x is greater than y” else echo “y is greater than x” fi