BIG

 

shell script - bash - Loop statement sample code

 

#!/bin/bash

# A simple 'for' loop
for i in 1 2 3 4 5; do
  echo $i
done

# A 'for' loop using the 'seq' command
for i in $(seq 1 5); do
  echo $i
done

# A 'while' loop
j=1
while [ $j -le 5 ]; do
  echo $j
  j=$((j + 1))
done
LIST