On Tue, 11 Feb 2003 11:07:16 -0500, Gordon <[EMAIL PROTECTED]> 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 >f alternative, indirect, approach: if expr $var + 0 >/dev/null 2>&1; then echo number else echo not a number fi -- [EMAIL PROTECTED] -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list