公告
财富商城
积分规则
提问
发文
2019-03-10 13:00发布
放我归山
I came across a shell script that contains a statement like,
if [ $val -eq $? ]
What does $? mean here?
$?
$# = number of arguments. Answer is 3.
$#
3
$@ = what parameters were passed. Answer is 1 2 3.
$@
1 2 3
$? = was last command successful. Answer is 0 which means 'yes'.
0
I found that the link is very useful and is the great answer. It includes clearly expression with sample.
This is the value of the exit status of the previous command. This is 0 in case of success.
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
$
$val
val
ls *.* or ls would produce the same result. Meaning show zero or more files with any extension in the current directory.
ls *.*
ls
echo $? would display the exit status. If at least one file is displayed from the last command ,the exit status would be zero(success).
echo $?
$? is the last result of an exit-status ... 0 is by default "successfull"
bash# ls *.* bash# echo $? bash# 0 bash# ls /tmp/not/existing/ bash# echo $? bash# 2
最多设置5个标签!
$#
= number of arguments. Answer is3
.$@
= what parameters were passed. Answer is1 2 3
.$?
= was last command successful. Answer is0
which means 'yes'.I found that the link is very useful and is the great answer. It includes clearly expression with sample.
This is the value of the exit status of the previous command. This is
0
in case of success.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 variableval
ls *.*
orls
would produce the same result. Meaning show zero or more files with any extension in the current directory.echo $?
would display the exit status. If at least one file is displayed from the last command ,the exit status would be zero(success).$? is the last result of an exit-status ... 0 is by default "successfull"