bash - How can I test if a variable is *not* a positive integer? -


to test whether variable e.g. number greater 0, write:

((i > 0)) 

but how test if variable not number greater 0?

edit

sorry typo, meant not number greater 0.

edit 2

sry poor question. value of variable passed commandline argument, may number or not. needs checked.

for checking on not being number, have test regex. have used -5 instead 0 demonstrate more general case (my assumption use integers):

#!/bin/bash  a=$1  if [[ $a =~ ^[\-0-9]+$ ]] && (( > -5));   echo "a number , greater -5" else   echo "a not number or <= -5" fi 

if want test non-integers, have clarify in question considered number.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -