Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test if argument is integer 1

Status
Not open for further replies.

Calator

Programmer
Feb 12, 2001
262
AU
Hi, in a ksh script need to test if argument passed on command line is numeric (integer). Thanks.
 
In the ksh man page take a look at the typeset builtin (-i).

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
For the korn shell:

function is_integer {
[[ $1 = ?([+-])+([0-9]) ]]
}

is_integer $i && echo "yes" || echo "no"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top