for loop range not working ksh
16,871
I think from memory that the standard ksh
on AIX is an older variant. It may not support the ranged for loop. Try to run it with ksh93
instead of ksh
. This should be in the same place as ksh
, probably /usr/bin
.
Otherwise, just use something old-school like:
i=1
while [[ $i -le 10 ]] ; do
echo "Welcome $i times"
i=$(expr $i + 1)
done
Actually, looking through publib seems to confirm this (the ksh93
snippet) so I'd try to go down that route.
Author by
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
I tried this,
#!/bin/ksh for i in {1..10} do echo "Welcome $i times" done
in Ksh of an AIX box. I am getting the output as,
Welcome {1..10} times
What's wrong here? Isn't it supposed to print from 1 to 10?. Edit: According to perkolator's post, from Iterating through a range of ints in ksh?
It works only on linux. Is there any other work around/replacements for unix box ksh?
for i in 1 2 3 4 5 6 7 8 9 10
is ugly.
Thanks.