-
Does Anyone know....
....how to use basic arithmetic options in a case state statement and then loop them with say, a "while" loop? Please be gentle as I am definitely a newbie.
Example: Very simple option "case statement" for these alltogether.
sum=$((num1 + num2))
diff=$((num1 - num2))
prod=$((num1 *\ num2))
quot=$((num1 / num2))
and then "while" looped.
thanks,
joe.
-
This looks like a homework to me.
Don't do much Bash script myself by a quick Google with "while in BASH" turns up
Code:
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 10 ]; do
echo The counter is $COUNTER
let COUNTER=COUNTER+1
done
You need a counter of some sort to test when to stop as your script is just playing with two numbers without any ending.
If you insert your text into the middle of the above, say after the line echo, your script will be executed 10 times when $COUNTER exceed 10.