#! /bin/sh
if [ $? -ne 0 ]; then
echo "Failed to execute"
else
echo "execution succeed"
fi
这篇博客解释了一个简单的shell脚本,展示了如何通过条件语句检查命令执行的返回状态,判断是成功还是失败,并给出了相应的输出消息。
#! /bin/sh
if [ $? -ne 0 ]; then
echo "Failed to execute"
else
echo "execution succeed"
fi
964

被折叠的 条评论
为什么被折叠?