Writing a bash for-loop with a variable top-end

后端 未结 3 1213
萌比男神i
萌比男神i 2021-01-04 01:00

I frequently write for-loops in bash with the well-known syntax:

for i in {1..10}  [...]

Now, I\'m trying to write one where the top is def

3条回答
  •  甜味超标
    2021-01-04 01:12

    If you have a gnu system, you can use seq to generate various sequences, including this.

    for i in $(seq $TOP); do
        ...
    done
    

提交回复
热议问题