Back
Close

Computing with Data

elgeish
33.3K views

Bash - Loops

# Example: the seq command
seq 1 5
echo seq 1 5
echo `seq 1 5`
# Example: for-loops
for i in `seq 1 5`; do echo the current number is $i; done
# parentheses start a new sub-shell
for i in `seq 1 5`; do (echo the current number is $i| wc); done
# Example: while-loops
i=0; while [ $i -lt 5 ]; do echo $i; let i=i+1; done
# Example: until-loops
i=0; until [ $i -ge 5 ]; do echo $i; let i=i+1; done
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants