Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unix bash script

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Write a bash script named addem that reads a list of numbers (on seperate lines) until teh number 999 is read, and then prints the total of all the numbers added up. It must contain the while loop and exit when the number 999 has been entered. Here is what i have. What do i need to do to this.

echo "Enter a number (999 to quit) "
read $n
while $n -ne 999
$sum += $n;
echo "enter another number (999 to quit) "

echo "The sum is $sum"
exit
done
 
hey buddy I got the answer for you. Here what I have and it work.call 670-8059

Echo "Enter the num:"
read num
nnum=0
while [ $num -ne 999 ] ; do
nsum=$[$nsum + $sum]
echo "Enter Another num"
read num
done
echo $nsum


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top