for loops
Jim Rogers
jimr at hplsdv7.COS.HP.COM
Fri Apr 5 02:22:33 AEST 1991
/ hplsdv7:comp.unix.shell / edh at ux.acs.umn.edu (Merlinus Ambrosius) / 4:14 pm Apr 2, 1991 /
In sh, I'd like to do something like a BASIC for loop. Say I have $FILES
set to some number, and I'd like to go through a loop $FILES times. Can
this be done in sh?
Thanks!
--eric
----------
Try the following:
#!/bin/sh
foo=10
count=0
while [ $count -lt $foo ]
do
echo $count
count=`expr $count + 1`
done
The "expr" command evaluates arguments as an expression and writes the
result to stdout.
Jim Rogers
Hewlett-Packard Company
Colorado Springs, Colorado
More information about the Comp.unix.shell
mailing list