substituting a string in place of variable in shell

前端 未结 2 470
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-10 13:35

I pass a string as an argument to a shell script. and the shell script should tell me if the passed argument is a variable

something like this

if [ ! -z          


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-10 14:19

    The syntax for this is:

    ${!VAR}
    

    Example:

    $ function hello() { echo ${!1}; }
    $ hello HOME
    /home/me
    

提交回复
热议问题