test或[命令
test用法:检查一个文件是否存在。
if test -f fred.c
then
...
fi
或
if [ -f fred.c ]
then
...
fi
#!/bin/sh
echo "Is it morning?Please answer yes or no"
read timeofday
if [ $timeofday = "yes" ]; then
echo "Good morning"
else
echo "Good afternoon"
fi
exit 0
如果你用 脚本 a 调用 脚本b ,要在a中判断b是否正常返回,就是根据 exit 0 or 1 来识别。