ksh while loop | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

ksh while loop

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-04-2007
scriptingmani scriptingmani is offline
Registered User
 
Join Date: Jun 2007
Last Activity: 2 July 2009, 9:18 AM EDT
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  
Advisor
 
Join Date: Mar 2006
Last Activity: 8 October 2014, 1:35 AM EDT
Location: Bangalore,India
Posts: 2,089
Thanks: 12
Thanked 131 Times in 126 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
Last Activity: 24 October 2014, 6:58 PM EDT
Location: Almerķa, Spain
Posts: 777
Thanks: 24
Thanked 110 Times in 105 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
scriptingmani scriptingmani is offline
Registered User
 
Join Date: Jun 2007
Last Activity: 2 July 2009, 9:18 AM EDT
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 12:41 PM.