Any reason why this thing doesn't works in Korn Shell
for (( expr1; expr2; expr3 ))
do
..... ... repeat all statements between do and done until expr2 is TRUE Done
Rgds,
TS
Any reason why this thing doesn't works in Korn Shell
for (( expr1; expr2; expr3 ))
do
..... ... repeat all statements between do and done until expr2 is TRUE Done
Rgds,
TS
This only works with kornshell 93, not kornshell 88.
And how to identify which korn shell is there on my OS?
Rgds,
TS
If you have a shell variable $KSH_VERSION, you are on ksh93. You can also probe for other features.
You also can try to call your ksh with --version
as argument, ksh88 does not print anything
$ /opt/ast/bin/ksh --version
version sh (AT&T Research) 1993-12-28 s
$ /bin/ksh --version
$
Assuming your version of the Korn shell handles ((...)) in for loops, you've got the logic backwards.
for (( expr1; expr2; expr3 ))
do statements...
done
executes the specified statements each time expr2 evaluates to TRUE and leaves the loop when expr2 evaluates to FALSE. For example:
for (( i=1; i<5; i++))
do echo $i
done
produces the output:
1
2
3
4
because i<5
is true the 1st four times through the loop.