Loops in UNIX Shell Scripts - while Statement

The while construct allows iterations through a block of script as long as a certain condition is true.

Syntax:

while condition
do
commands
done

Example:

The example script counts up to10 secs.

#!/bin/sh

i=1
while [ $i -le 10 ];
do
   sleep 1
   print "$i"
   i=` expr $i + 1 `
done

exit 0

Comments

Popular posts from this blog

OS/DB Migration - CMD. STR, TOC, EXT, R3load, DDLDBS.TPL and more

Fixing Inconsistent Table - Table activation fails due to inconsistency between DD and DB

301 Redirect Using SAP Web Dispatcher