Hi all, im new to the forums and i hope im not asking a heavily posted Q but here goes.
I use the following script to do a simple calculation, the problem is, the data i receive is in the form of numbers with commas i.e.
1,000,000
This code below wont recognise the commas so i have to remove them. If anyone has a simple solution or even point me in the right direction that would be grand. It's a little hard to search for an error with such a common word like "comma".
#! /bin/bash
echo "What is the Lowest Threshold?" ;
read LOW ;
echo "What is the highest Threshold?";
read HIGH ;
echo "How much data have you received?";
read DATA ;
THRESHOLD=`expr $HIGH - $LOW` ;
if [ "$DATA" -gt "$HIGH" ] ; then
DIFF=`expr $DATA - $HIGH` ;
DATA=`echo "scale=2; ( $DIFF / $THRESHOLD ) * 100" | bc` ;
echo "$DATA percent above the threshold.";
echo "Press 'enter' to continue" ;
read cont ;
elif [ "$DATA" -lt "$LOW" ] ; then
DIFF=`expr $LOW - $DATA` ;
DATA=`echo "scale=2; ( $DIFF / $THRESHOLD ) * 100" | bc` ;
echo "$DATA percent below the threshold.";
echo "Press 'enter' to continue" ;
read cont ;
else
echo "This data is within the threshold limits.";
echo "Press 'enter' to continue";
read cont ;
fi;
Thanks if anyone can help.