Trouble with a basic bash script
Hi
I'm new to bash scripting in linux. I'm trying to make a script that reads numbers users write and then adds them. This is what I've written so far.. #!/bin/bash # A script that adds numbers NUMBER=0 sum=0 declare -i number echo "Enter a number" read NUMBER for add in * do if [ $NUMBER = $number ] then $NUMBER+=$sum echo "Plz enter a new number, quit with a character" read NUMBER return fi #done echo "You did not enter a number! The sum added up is $sum" exit 0 |
What kind of errors are you getting? Why are you declaring the values of NUMBER and sum in the script as 0's? If these are suppose to be read by the person entering them, I would think you don't need these?
|
I'm quite new to this..
What I'm trying to do is to let a user define values that "my" script will add up. Do you have any solution to this?? Plz help.. |
Plz help.. schoolwork need to be done by tomorrow
Please read the LQ rules: don't ask us to do your homework. |
Ooops so sorry... didn't know that.. but now I do
|
And now you do. ;)
Thread closed. |
All times are GMT -5. The time now is 05:36 AM. |