Accessing shell script arguments by index

前端 未结 2 605
借酒劲吻你
借酒劲吻你 2020-12-10 21:53

I\'m sure this is a no-brainer when you\'re into shell programming. Unfortunately I\'m not and I\'m having a pretty hard time ...

I need to verify arguments passed t

2条回答
  •  醉酒成梦
    2020-12-10 22:44

    In bash, you can use indirect parameter expansion to access an arbitrary positional parameter.

    $ set a b c
    $ paramIndex=2
    $ echo $2
    b
    $ echo ${!paramIndex}
    b
    

提交回复
热议问题