A Linux shell if [$ -eq 0?] Statement applies: to determine whether the command is executed successfully

shell script $? refers to the success or failure of the status of the last command executed. If success is 0, 1 failure .. Statement if [$? -Eq 0] to determine if the statement is a command if it fails to execute if statements, or else on the implementation of the contents of.

note: To be used with caution, in parentheses behind if [$ -eq 0?], both sides of the brackets need to have a space.

cd u-boot && ./make.sh $RK_UBOOT_DEFCONFIG && cd -
if [ $? -eq 0 ]; then
        echo "====Build uboot ok!===="
else
        echo "====Build uboot failed!===="
        exit 1
fi
 

Published 447 original articles · won praise 71 · Views 400,000 +

Guess you like

Origin blog.csdn.net/w892824196/article/details/103985328