Mar 7, 2004 #1 cantubas Programmer Jan 8, 2004 45 FR is there a function to know if a variable is a number or no ??? to know if a variable is a number I do: if (( parametres = $parametres + 0 )) then echo "it's a number" else echo "it is not a number" fi ... does another solution exist?
is there a function to know if a variable is a number or no ??? to know if a variable is a number I do: if (( parametres = $parametres + 0 )) then echo "it's a number" else echo "it is not a number" fi ... does another solution exist?
Mar 8, 2004 1 #2 aigles Technical User Sep 20, 2001 464 FR With ksh, you can do : Code: if [[ "$parametres" = +([0-9]) ]] then echo "it's a number" else echo "it is not a number" fi Jean Pierre. Upvote 0 Downvote
With ksh, you can do : Code: if [[ "$parametres" = +([0-9]) ]] then echo "it's a number" else echo "it is not a number" fi Jean Pierre.
Mar 12, 2004 #3 SamBones Programmer Aug 8, 2002 3,186 US In the Korn shell you can force a variable to only accept numeric characters... Code: typeset -i parametres From that point on, it will only accept integer values. Hope this helps. Upvote 0 Downvote
In the Korn shell you can force a variable to only accept numeric characters... Code: typeset -i parametres From that point on, it will only accept integer values. Hope this helps.