测试命令的退出状态

退出状态 0:成功
退出状态不是 0:失败

要测试命令的退出状态:

if command;then
    echo 'success'
else
    echo 'failure'
fi