Looping and Skipping

Sort by

recency

|

249 Discussions

|

  • + 0 comments
    #!/bin/bash
    for i in {1..100}; do
    if [ `expr $i % 2` != 0 ];
    then echo $i
    fi;
    done
    
  • + 0 comments

    i=0; for((i=1; i<=99; i++ )) do if (( i%2 != 0 )) then echo $i fi

    done

  • + 1 comment

    just

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

  • + 0 comments
    i=1
    while [ $i -le 99 ]
    do
    echo $i
    i=$((i+2))
    done
    
  • + 0 comments

    try this one

    for ((i=1; i<=100; i+=2)); do
        echo $i
    done