bash – “${!var}”在shell脚本中的含义是什么?
参见英文答案 >
What is indirect expansion? What does ${!var*} mean?????????????????????????????????????4个
我有一个具有以下条件的代码块,不知道它究竟是做什么的. $var = "${args}_Some_Text" if [ "${!var}" == '' ];then echo "$var is not defined !!!" fi 解决方法
这称为可变间接扩展.
$hello="this is some text" # we set $hello $var="hello" # $var is "hello" $echo "${!var}" # we print the variable linked by $var's content this is some text 如您所见,这是一种定义“变量变量”的方法.也就是说,使用其内容是另一个变量名称的变量. 从Bash Reference Manual → 3.5.3 Shell Parameter Expansion开始:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |