[SunHELP] Korn shell  script
    DAUBIGNE Sebastien  - BOR (  SDaubigne@bordeaux-bersol.sema.slb.com ) 
    SDaubigne at bordeaux-bersol.sema.slb.com
       
    Wed Jun 26 05:41:25 CDT 2002
    
    
  
I'm afraid "for 1 to 10" is not valid in KSH.
You'd better use "while" or "for i in 1 2 3 5 6 7 8 9 10".
Example :
i=1
while [ $i -lt 10 ]
do
  ((i=i+1))
done
echo $i
For the increment, you can use either :
((i=i+1))
or :
let i=i+1
which is equivalent.
((i++)) is not valid in KSH.
---
Sebastien DAUBIGNE
sdaubigne at bordeaux-bersol.sema.slb.com <mailto:sebastien.daubigne at sema.fr>
- (+33)5.57.26.56.36
SchlumbergerSema - Sema Global Services - DW/Pessac
	-----Message d'origine-----
	De:	Sangbutsarakum, Patai [SMTP:patais at reach.com]
	Date:	mercredi 26 juin 2002 11:19
	:	'sunhelp at sunhelp.org'
	Objet:	[SunHELP] Korn shell  script
	if i need to count the number of for loop
	for 1 to 10  do {
		i=i+1;
	}
	echo "$i";
	I have headache with 'i=i+1',
	what is it in Korn shell.?
	Somewhere i saw use 'let', ((i=$i+1)), ((i++))
	Please suggest
	Pat.
	_______________________________________________
	SunHELP maillist  -  SunHELP at sunhelp.org
	http://www.sunhelp.org/mailman/listinfo/sunhelp
    
    
More information about the SunHELP
mailing list