Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

ksh while loop

Shell Programming and Scripting


Closed    
 
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: 7 November 2016, 6:31 AM EST
Location: Bangalore,India
Posts: 2,152
Thanks: 21
Thanked 159 Times in 150 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: 3 October 2016, 11:00 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

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-06-2011 12:42 AM
BASH loop inside a loop question rethink Shell Programming and Scripting 4 09-15-2010 08:58 AM
Null Handling in Until loop. . .loop won't stop brandono66 Shell Programming and Scripting 4 11-24-2009 04: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 05:59 PM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 12:09 PM



All times are GMT -4. The time now is 11:48 PM.