How can I test if a variable is *not* a positive integer?
bash
Solution
For checking on not being number, you have to test with regex. I have used `-5` instead `0` just to demonstrate more general case (My assumption is that you use integers):
#!/bin/bash
A=$1
if [[ $A =~ ^[\-0-9]+$ ]] && (( A > -5)); then
echo "A is number and is greater then -5"
else
echo "A is not a number or is <= -5"
fi
If you want to test for non-integers, you have to clarify in your question what is considered number.
Problem
To test whether a variable is e.g. a number greater than 0, you would write: ``` ((i > 0)) ``` But how would I test if the variable is `not` a number greater than 0? EDIT Sorry for the typo, meant `not a number greater than 0`. EDIT 2 Sry for the poor question. The value of the variable is passed as a commandline argument, so it may be a number or not. This also needs to be checked.