シェルの戻り値(正常終了か否か)

$?でシェルが正常終了したかどうかが確認できます
正常終了:0、正常終了でない:0以外

[root@hoge ~]# ls -l file3; echo $?
ls: file3: そのようなファイルやディレクトリはありません
2
[root@hoge ~]# ls -l; echo $?
合計 44
-rw------- 1 root root  1043  5月 20  2009 anaconda-ks.cfg
-rw-r--r-- 1 root root 22427  5月 20  2009 install.log
-rw-r--r-- 1 root root  3063  5月 20  2009 install.log.syslog
0