i don't get what's wrong here. i'm writing a shell script that takes 1 argument (a number) from the command-line, but it's throwing an error:
Syntax error: Bad for loop variable
doesn't make much sense
for (( i = 1; i = ${1}; i++ )) # error points to this line everytime
do
echo "Welcome $i times"
done
i've tried changing it several times, but it always throws the same error. what's the problem with it?
This version of ksh accepts the extended for syntax:
#!/bin/ksh
# @(#) s1 Demonstrate for loop in ksh.
echo
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1)
N=3
echo
for (( i = 1; i <= ${N}; i++ ))
do
echo "Welcome $i times"
done
exit $?
producing:
$ ./s1
(Versions displayed with local utility "version")
Linux 2.6.24-1-686
ksh 93s+
Welcome 1 times
Welcome 2 times
Welcome 3 times
I will say I was surprised to find this AT&T version of ksh in Debian Lenny rather than the previous pdksh, but it makes life easier in some situations. Solaris 10 still has pdksh as the default ksh [edit: this is not true, see post below] ... cheers, drl
Sorry for the tone of my post, I didn't mean to flame and obviously I didn't know what I was talking about. Looks like I need to examine the Bash manual more closely.