![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why does my script not work? (Noob Alert) | bronkeydain | Shell Programming and Scripting | 4 | 02-21-2008 12:45 PM |
| noob. need help to create a script. | aron | Shell Programming and Scripting | 1 | 07-09-2007 05:13 PM |
| sed formatting query | gopsman | Shell Programming and Scripting | 2 | 05-10-2007 12:07 AM |
| sed formatting query | gopsman | Shell Programming and Scripting | 2 | 05-09-2007 06:46 AM |
| Using PHP script with crontab (NOOB) | Bobafart | UNIX for Dummies Questions & Answers | 5 | 04-26-2007 06:32 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Noob, script formatting query
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". Code:
#! /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;
|
| Forum Sponsor | ||
|
|