Gordon wrote:
I've searched all over for an answer to this and haven't found one yet!
Is there a way in a bash script to test if a variable contains an
integer? I want to create a script that uses some simple arithmetic but
bash bombs out if you try to do a comparison or arithmetic with a
non-numeric value. Basically, something like:
read var
if [ "$var" is a number ]; then
do something
else
echo var is not a number
fi
How about a case statement:
case $var in
1234567890)
do something;;
*)
echo $var is not a number
esac
That will only work for single-digit numbers.
Tony
--
Anthony E. Greene <mailto:[EMAIL PROTECTED]%3E>
OpenPGP Key: 0x6C94239D/
AOL/Yahoo Chat: TonyG05 HomePage: <http://www.pobox.com/~agreene/>
Linux. The choice of a GNU generation. <http://www.linux.org/>
--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list