How do I iterate over a range of numbers defined by variables in Bash?

后端 未结 20 1964
予麋鹿
予麋鹿 2020-11-21 05:19

How do I iterate over a range of numbers in Bash when the range is given by a variable?

I know I can do this (called \"sequence expression\" in the Bash documentatio

20条回答
  •  无人及你
    2020-11-21 06:05

    This works fine in bash:

    END=5
    i=1 ; while [[ $i -le $END ]] ; do
        echo $i
        ((i = i + 1))
    done
    

提交回复
热议问题