On Sun, 29 Jun 2003 11:50:06 +0200, David selby 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 ..
[...]
> kind of thing, but this is not BASIC !!

... and honestly, I'm glad it isn't BASIC ;-)

> My best guess is
> 
> declare -i n=1
> while [ $n < 9 ]; do
> .....
> n=$((n+=1))
> done


n=1
while [ $n \< 9 ]; do
        echo $n
        n=$((n+=1))
done

Note the backslash. Plain < is for redirection. Interesting to see that I
never ran into this thing, because I'm used to != from C++ :-)

Another possibility is along the lines of

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

> PS is there a more ellagent way to do a counted loop as well as a way 
> that works ?

*shrug* bash scripting and elegant? ;-)

-- 
Best Regards,   |   Hi! I'm a .signature virus. Copy me into
 Sebastian      |   your ~/.signature to help me spread!


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

Reply via email to