#!/bin/bash ############################################################################ # http://LinuxMeister.net/Scripts/while-loop.sh.html # SAMPLE: WHILE LOOP - counter john meister jun 2013 ############################################################################ # cat /dev/null > count.txt # clear output file X=1 # declare starting value X=1 echo "********************** counting to 10 *******************************" while [ $X -le 10 ] # while the count is less than 10 do echo ">>--> $X" | tee -a count.txt # display count and add to file X=$(( $X + 1 )) # increment variable by one sleep 1 # sleep for 1 second done echo "********************** done! ***************************************" ############################################################################