Iterate through parameters skipping the first

前端 未结 5 1974
野的像风
野的像风 2020-12-24 02:25

Hi i have the following:

bash_script parm1 a b c d ..n

I want to iterate and print all the values in the command line starting from a, not

5条回答
  •  一个人的身影
    2020-12-24 02:50

    You can use an implicit iteration for the positional parameters:

    shift
    for arg
    do
        something_with $arg
    done
    

    As you can see, you don't have to include "$@" in the for statement.

提交回复
热议问题