Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

ksh while loop

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 07-04-2007
anbu23's Unix or Linux Image
anbu23 anbu23 is offline Forum Advisor  
Advisor
 
Join Date: Mar 2006
Last Activity: 16 March 2015, 4:56 AM EDT
Location: Bangalore,India
Posts: 2,136
Thanks: 14
Thanked 150 Times in 143 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 Unix and Linux 07-04-2007
Klashxx's Unix or Linux Image
Klashxx Klashxx is offline Forum Advisor  
HP-UX/Linux/Oracle
 
Join Date: Feb 2006
Last Activity: 8 June 2015, 7:38 AM EDT
Location: Almerķa, Spain
Posts: 779
Thanks: 24
Thanked 112 Times in 106 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 Unix and Linux 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.Linux
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 08:34 AM.