Non Numeric Argument Error

hi there,
I was recently introduced to this site by a friend. I hope you guys can help with a code error i can't seem to debug.I can get to add two different data types together. A snippet of the code is below:

echo -n "Enter Your MOnthly Investment"
read Inv
PIP= $(echo "scale=2; 10 / 100" | bc)
Amt=`echo $PIP "" $Inv | bc`
PIP2= $(echo "scale=2; 15 / 100" | bc)
var=`echo $PIP2 "
" $Inv | bc`
Gr=`expr $Inv + $Amt`
Gross=`expr $Gr - $var`
echo "Your Accrued PIP amount is: $Amt"
echo "Your Accrued PIP2 amount is: $var"
echo "Gross Amount on your investment is: $Gross"

where is code error ?
which os, shell are you using ?

  • nilesh

It is best to try and be consistent in the way you handle variables and the math. The following uses the same format for all math functions - and no longer has errors.

#/ usr/bin/bash

echo -n "Enter Your Monthly Investment "
read Inv
PIP=$(echo "scale=2; 10 / 100" | bc)
Amt=$(echo $PIP "*" $Inv | bc)
PIP2=$(echo "scale=2; 15 / 100" | bc)
var=$(echo $PIP2 "*" $Inv | bc)
Gr=$(echo $Inv + $Amt | bc)
Gross=$(echo $Gr - $var | bc)
echo "Your Accrued PIP amount is: $Amt"
echo "Your Accrued PIP2 amount is: $var"
echo "Gross Amount on your investment is: $Gross"

Thanks alot joeyg. You're the bomb. Pls can u suggest an ebook i can download and read on shell scripting that would be of immense benefit. I appreciate

See this link on this forum.
I'm new to Unix. Which books should I read? - The UNIX and Linux Forums

Other than that, it is often trial and error until you master the commands. One suggestion I often make is to try to solve the problem in small parts with lots of 'echo' commands to track your progress. Once you resolve and know your data is good, you can then delete out all of the lines of 'echo's. This is especially important as you learn how to use new commands.

And of course, use this site as a reference. Hopefully you will become comfortable enough so that you may also be able to contribute and help answer questions for others.