Register
It is currently Sat Oct 25, 2014 7:07 pm

Help with writing a while/until loop


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sat May 17, 2008 4:48 pm   

Joined: Thu May 08, 2008 3:23 am
Posts: 4
I am trying to writ a while/until loop that will add some inputed numbers together. Is there a way that I can say while "something" does not equal a letter or until "something" equals a number? Is there an easier way to write a script like this?


Top
 Profile  
 PostPosted: Sun May 18, 2008 1:31 pm   

Joined: Thu May 08, 2008 3:23 am
Posts: 4
This is what I got so far but it gives me an error and says command not found! Any help would be appreciated...

#!/bin/bash
echo
echo -n "Sum for: "
read input

until $input == [0-9]
do
echo -n $input " + "
varname='expr $var + $input'
done
echo -n " = " $var
echo


#!/bin/bash
echo
echo -n "Sum for: "
read input

while $input != [a-zA-Z]
do
echo -n $input " + "
var='expr $var + $input'
done
echo -n " = " $var
echo


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP