validating variables (numeric)

Hi

I need to get a user to enter a number (an exchange rate) into a script. I have the following:

#!/bin/ksh
echo "Enter exchange rate:"
read EX_RATE
if [ -z "`echo \"$EX_RATE\" | tr -d \"[:digit:]\"`" ]
then
echo "Well done - only numeric here"
else
echo "Not so well done - there is NON numeric stuff here!"
fi

This works fine except when I try to enter a decimal number when it exits because the decimal point is obviously non-numeric. I have looked at the other class keywords and there is not one that covers decimals.

Can anyone help me out here?

thanks

Paul

if [ -z "`echo \"$EX_RATE\" | tr -d \"[0-9\.]\"`" ]

try this

echo "Enter exchange rate:"
read EX_RATE
if [ -n "`echo \"$EX_RATE\" | sed -n "/^[0-9.]\{1,\}$/p"`" ]
then
echo "Well done - only numeric here"
else
echo "Not so well done - there is NON numeric stuff here!"
fi

many thanks guys - both answers work a treat.