what does '$?' mean in a shell script?

前端 未结 6 2007
抹茶落季
抹茶落季 2021-02-02 00:31

I came across a shell script that contains a statement like,

if [ $val -eq $? ]

What does $? mean here?

6条回答
  •  眼角桃花
    2021-02-02 01:20

    $?
    

    returns the status of the last finished command. Status 0 tells you that everything finished ok.

    In addition the $ sign is a special symbol - and in that case $val extract the value that is hold by the variable val

提交回复
热议问题