Store Bash script arguments $@ in a variable

前端 未结 2 415
[愿得一人]
[愿得一人] 2021-01-01 05:52

How can I store $@ in a variable while keeping its properties?

I want to obtain exactly the same behavior even if I use $@ or my own varia

2条回答
  •  时光说笑
    2021-01-01 06:25

    You can store it in an array:

    args=("$@")
    

    then you can access each of the arguments with index: "${args[index]}" and all arguments at once with "${args[@]}".

提交回复
热议问题