Talk:Determine if a string is numeric

From Rosetta Code
Revision as of 20:42, 22 January 2007 by 80.126.52.220 (talk) (Unix shell)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Unix shell

#!/bin/sh

a='123'
if [ "$a" -eq "$a" ] 2>/dev/null
then
    echo "a is numeric"
else
    echo "a is abnumeric"
fi