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

后端 未结 20 1962
予麋鹿
予麋鹿 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:03

    If you need it prefix than you might like this

     for ((i=7;i<=12;i++)); do echo `printf "%2.0d\n" $i |sed "s/ /0/"`;done
    

    that will yield

    07
    08
    09
    10
    11
    12
    

提交回复
热议问题