Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

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
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content