How do I test if a variable is a number in Bash?
Asked 07 September, 2021
Viewed 1.5K times
  • 58
Votes

I just can't figure out how do I make sure an argument passed to my script is a number or not.

All I want to do is something like this:

test *isnumber* $1 && VAR=$1 || echo "need a number"

Any help?

30 Answer