bash: while loop.



  • Take into account the main readme for this section. README first.

    Normally done with a shell script but for demonstration purposes the command line is used.

    Syntax while: while test-commands; do consequent-commands; done
    What does it do? Execute commands as long as a test succeeds.

    $ count=10
    $ while [[ $count -gt 5 ]]; do echo $count; ((count--)); done
    10
    9
    8
    7
    6
    

    Also see: bash: until loop.


Log in to reply
 

© Lightnetics 2024