UnixTips.net

* use my tips at your own risk !!

* use my tips at your own risk !!

Categories

  • Other (3)
  • Scripting (10)
  • Unix (70)
  • Wordpress (2)

Powered by Genesis

infinite ksh shell loop with count

So .. no thrills no frills. If you are searching for this .. you know what you are looking at and can modify this as needed.


#!/usr/bin/ksh

export PATH=$PATH:/sbin:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/usr/local/bin

DATE=`date '+%Y.%m.%d_%H.%M.%S'`

count=1
while true
do
    echo ${count}
    (( count++ ))

if [[ ${count} -eq 11 ]]; then
    count=1

fi
sleep 1
done

This script will run forever and output:

1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10