Looping with Numbers

Sort by

recency

|

100 Discussions

|

  • + 0 comments

    for i in {1..50};do echo $i;done

  • + 0 comments

    both:

    for i in {1..50}
    do
      echo $i
    done
    

    and:

    for i in {1..50}; do
      echo $i
    done
    
  • + 0 comments
    i=1
    while [[ $i -le 50 ]]
    do
    echo $i
    i=$(($i+1))
    done
    
  • + 0 comments
    for i in {1..50}
    do
        echo $i
    done
    
  • + 0 comments

    limit=50

    Define a variable to start the loop

    num=1

    Loop until num reaches the limit

    while [ limit ] do # Print the current value of num echo $num

    # Increment num by 1 for the next iteration
    ((num++))
    

    done