The following blog post shows example of bash script with for loop, while loop, if elif else conditional statements.
- Conditional while loop
- While loop to iterate over lines in a file
- Infinite while loop with break and continue
- Infinite while loop with sleep
- Iterate over arguments passed as input using for loop
- For loop with counter
- if..elif..else conditional structure
- Numerical comparison
- String comparison
- Regular Expression match
- and (&&), or (||), not (!) conditions
- Expression with multiple conditions
bash loops.sh --help
bash conditionals.sh