'$' 是什么?在shell脚本中是什么意思? [英] what does '$?' mean in a shell script?

查看:60
本文介绍了'$' 是什么?在shell脚本中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个包含如下语句的 shell 脚本,

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

if [ $val -eq $? ]

$? 在这里是什么意思?

推荐答案

$?

返回最后完成的命令的状态.状态 0 表示一切正常.

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

此外,$ 符号是一个特殊符号 - 在这种情况下 $val 提取由变量 val 保存的值

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

这篇关于'$' 是什么?在shell脚本中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆