Bourne Shell For i in (seq)

后端 未结 6 851
陌清茗
陌清茗 2020-12-29 10:37

I want to write a loop in Bourne shell which iterates a specific set of numbers. Normally I would use seq:

for i in `seq 1 10 15 20`
   #do stuf         


        
6条回答
  •  隐瞒了意图╮
    2020-12-29 11:11

    for i in `seq 1 5 20`; do echo $i; done
    

    Result:

    5
    10
    15
    20
    

    $ man seq

    SEQ(1)                           User Commands                          SEQ(1)
    
    NAME
           seq - print a sequence of numbers
    
    SYNOPSIS
           seq [OPTION]... LAST
           seq [OPTION]... FIRST LAST
           seq [OPTION]... FIRST INCREMENT LAST
    

提交回复
热议问题