We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
[ .. ]
[[ .. ]]
if [ $var == *[^0-9]* ] then echo "$var is not numeric" fi
if [[ $var == *[^0-9]* ]] then echo "$var is not numeric" fi
[ .. ] aka test can not match against globs.
test
In bash/ksh, you can instead use [[ .. ]] which supports this behavior.
In sh, you can rewrite to use grep.
grep
if echo $var | grep -q '^[0-9]*$'; then echo "$var is numeric" fi
None. If you are not trying to match a glob, quote the argument (e.g. [ $var == '*' ] to match literal asterisk.
[ $var == '*' ]