On Sat, June 28 at  3:03 PM EDT
David selby <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> I am writing bash a bash & sed script, it has been going suprisingly 
> well. I need a loop to count 9 times & the variable n to the count ..
> 
> for n=1 to 9
> ....
> next
> 
> kind of thing, but this is not BASIC !!
> 
> My best guess is
> 
> declare -i n=1
> while [ $n < 9 ]; do
> .....
> n=$((n+=1))
> done
> 
> All i get is ...
> 
> [EMAIL PROTECTED]:/usr/local/myfiles/dave/websites/kcards$ ./gensite
> ./gensite: 9: No such file or directory
> 
> I have defined it as an integer, used the less than operator for 
> integers, ... errr ... I know its something stupid but I can't crack
> it ....
> 
> Dave
> 
> PS is there a more ellagent way to do a counted loop as well as a way 
> that works ?

I can tell you what I usually do but I bet there are better ways.

for n in $(seq -w 1 9); do echo $n; done

Then seq -w means that if I have some digits with 2 or more positions it
will pad the lower numbers with 0's in front so they are all equal
width.
If you know the exact number of loops you want this way should work.

Shawn Lamson
[EMAIL PROTECTED]
Debian GNU/Linux 3.0


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to