Loops

The purpose of this document is to show how to use loops in Bash.

# The array for loop files=( "/etc/passwd" "/etc/group" "/etc/hosts" ) for i in "${arrayName[@]}" do # do whatever on $i done

days=( 23 24 25 26 27 28 30 31 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ) for day in "${days[@]}" ; do /opt/jgs/data.sh >> /var/log/jgs/data.log 2>&1 ; done

Forever loop:

while : do echo "Press [CTRL+C] to stop.." sleep 1 done

[Edit]