From: John Gaughan (jgaughan at domain irish-times.com)
Date: Wed 03 May 2000 - 13:54:13 IST
> -----Original Message-----
> From: ilug-admin at domain linux.ie [mailto:ilug-admin at domain linux.ie]On Behalf Of Niall
> Sent: 03 May 2000 13:28
> Cc: ilug at domain linux.ie
> Subject: Re: [ILUG] shell script question
>
> On Wed, 3 May 2000, John N S Gill wrote:
>
> > Following works in bash:
> >
> > i=0
> > while [ $i -lt 256 ]; do
> > echo $i
> > i=$(( $i + 1 ))
> > done
>
> Whoops - sure makes my concatenating variables thing look every bit as bad
> as it is. But of course this won't work in sh (ssh! - don't mention expr -
> anyway, thing of the overhead of all those expr calls :-) )
It would work in ksh though, but to do that in sh you could use the expr
command instead of the shell's arithmetic expansion (which was added in ksh)
to increment the counter e.g.:
x=1
while [ $x -lt 256 ]
do
echo $x
x=`expr $x + 1`
done
John.
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:00 GMT