gpt4 book ai didi

linux - $?在 shell 脚本中

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:35:01 24 4
gpt4 key购买 nike

我试图弄清楚这意味着什么/$? 如何在 linux 中填充,我尝试进行搜索,但如果有人能澄清那会很棒:

exitstat=$?

if [ $exitstat -ne 0 ]
then
echo -e "Could Not Extract"
echo -e "Aborting Script `date`"
exit $exitstat
fi

上面的代码是:

_xfile << %%  2> /files/thefile-7000.log |  _afile -x -r 10 2> /files/thefile-7000.log > /files/thefile.7000
OperatorHigh = $finalnumber
%%

最佳答案

$? 扩展为最近的前台命令的退出状态。

由于您之前的命令是管道,退出状态是管道中最后一个命令的退出状态——在本例中,_afile——除非 pipefail shell 选项已设置,在这种情况下,管道中其他地方的故障也会使退出状态不为零。

关于linux - $?在 shell 脚本中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36294923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com