Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-04-2007
Registered User
 
Join Date: Jun 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
ksh while loop

hi all,

got this silly problem and i just can't seem to make sense of the error message its is saying 1400: cannot open. its my first time at writing a while loop but tried all sorts to get it working without success.

#!usr/bin/ksh

integer max=1400
set file="afilename"
integer i=1

while i < $max
do
# $(echo value of is : $i >> $file)
echo value i: $i
i = $i + 1
done


thanks

Mani
Sponsored Links
    #2  
Old 07-04-2007
anbu23's Avatar
anbu23 anbu23 is offline Forum Advisor  
Registered User
 
Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,952
Thanks: 6
Thanked 79 Times in 77 Posts

Code:
#!usr/bin/ksh

integer max=1400
set file="afilename"
integer i=1

while [[ $i -lt $max ]]
do
# $(echo value of is : $i >> $file)
echo value i: $i
(( i = i + 1 ))
done

Sponsored Links
    #3  
Old 07-04-2007
Klashxx's Avatar
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
 
Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 696
Thanks: 14
Thanked 84 Times in 80 Posts
Another "mathematical way":


Code:
max=1400
set file="afilename"
i=1

while (( i <= max ))
do
   # $(echo value of is : $i >> $file)
   echo value i: $i
   (( i += 1 ))
done

    #4  
Old 07-04-2007
Registered User
 
Join Date: Jun 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
thanks got it working.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
S# in a for loop - concatenate $(loop counter) fight4love Shell Programming and Scripting 5 07-05-2011 11:42 PM
BASH loop inside a loop question rethink Shell Programming and Scripting 4 09-15-2010 07:58 AM
Null Handling in Until loop. . .loop won't stop brandono66 Shell Programming and Scripting 4 11-24-2009 03:57 PM
Using variables created sequentially in a loop while still inside of the loop [bash] DeCoTwc Shell Programming and Scripting 2 06-23-2009 04:59 PM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 11:09 AM



All times are GMT -4. The time now is 03:27 PM.