[plug] check value type
Bernd Felsche
bernie at innovative.iinet.net.au
Wed Aug 27 13:08:52 WST 2003
On Wed, Aug 27, 2003 at 12:10:12PM +0800, Jon Miller wrote:
> Is there a way to check the "type" of a value. By this I would
> like to check if the value of a variable is either a string or
> number.
For _simple_ numbers, you can use 'expr'. Simply add zero and
check the return status.
More rigourously, you could use tr, sed, awk, etc to strip out
numeric patterns from a string and see if there's anything left;
which would indicate non-numeric.
The again, isn't "pi" numeric? :-)
--
/"\ Bernd Felsche - Innovative Reckoning, Perth, Western Australia
\ / ASCII ribbon campaign | I'm a .signature virus!
X against HTML mail | Copy me into your ~/.signature
/ \ and postings | to help me spread!
More information about the plug
mailing list