How to iterate over arguments in a Bash script

后端 未结 8 2700
长发绾君心
长发绾君心 2020-11-22 02:27

I have a complex command that I\'d like to make a shell/bash script of. I can write it in terms of $1 easily:

foo $1 args -o $1.ext
         


        
8条回答
  •  无人共我
    2020-11-22 03:12

    You can also access them as an array elements, for example if you don't want to iterate through all of them

    argc=$#
    argv=("$@")
    
    for (( j=0; j

提交回复
热议问题