Linux Shell 怎样获得命令的执行结果

find $path1 -maxdepth 1 -iname $moduleNameif ;then #$moduleCommand $result1 echo "result of find is OK"else echo "result of find is failed"fi大家好,我写了个以上的Shell 程序,在执行这个程序时,执行的结果始终未:result of find is OK,path1为... find $path1 -maxdepth 1 -iname $moduleNameif ;then #$moduleCommand $result1 echo "result of find is OK"else echo "result of find is failed"fi 家 我写 Shell 程序 执行 程序 执行 结 始终未:result of find is OK path1 传进 目录 moduleName 要查找 模块名 执行 管moduleName 指定 目录 否存 其执行结 始终 :result of find is OK 跟踪 if 语句处 结 始终 :if 知道 原 谢谢 由于 刚进 新手 故 题暂 没 悬赏 谢 给予答复 牛 谢谢 展开

可以用
$?
获取上一条shell命令的返回结果。
一般的约定是:
0
表示成功,非0表示失败。
例如:你可以试验一下
执行正确的shell
命令:
执行
ls,然后紧接着
echo
$?
执行错误的shell
命令:
执行
ls
/abcdefg,然后紧接着
echo
$?
温馨提示:答案为网友推荐,仅供参考