Free Step Dodge

tokiopewpew
tokiopewpew
Mhm ... I don't have that much experience with bash, but maybe I can help you anyway. What are you trying to do?
Fiend Busa
Fiend Busa
tokiopewpew
tokiopewpew
So ... if I understand right, you want to insert some numbers (specific ones?) and sum them up? I'm not sure what you mean with "my assignment wants me to exactly print this message out"
Fiend Busa
Fiend Busa
Basically if i did add2 4 -3 12 9

With my script it should output:22

If i did add2 4 -3 twelve nine
It should output
twelve
Sorry, 'twelve' is not a number
tokiopewpew
tokiopewpew
You mean you don't want it to echo out the second error message?
tokiopewpew
tokiopewpew
Or do you just want the sum as output, not every single number you typed?
Fiend Busa
Fiend Busa
Sum as output only
tokiopewpew
tokiopewpew
Or do you mean that it should print out "twelve" instad of some weird numbers?
Fiend Busa
Fiend Busa
If I did add2 2 3 nine it should print out

Nine

Sorry, nine is not a number
tokiopewpew
tokiopewpew
Ok, I understand.
Fiend Busa
tokiopewpew
tokiopewpew
Ok, what about this?


#!/bin/bash

echo -------
echo test

sum=0

for i in $@; do

if [[ $i != *[[:digit:]]* ]]
then
echo ""
echo "Sorry, '$i' is not a number, skipped"
else
sum=$[sum+$i]
fi

done

echo ""
echo "Summary: $sum"
tokiopewpew
tokiopewpew
Remove the echo commands at the top if you don't want to get your input printed. I just added them for tests.
Fiend Busa
Fiend Busa
Ok thanks ill try it out
Fiend Busa
Fiend Busa
it works but my assignment says its wrong fuck sake it wants me to output this to /dev/null but the shit is still echoing to the command line

echo $number | grep "[^a-z]" >> /dev/null
tokiopewpew
tokiopewpew
Fiend Busa
Fiend Busa
ye i have that, shit still wants to output the numbers i entered, god fucking dam this is annoying
ALL DOA6 DOA5 DOA4 DOA3 DOA2U DOAD
Top