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?
UPDATE: I managed (whit Charles' help) to do it, but I'm not yet sure it's the best way to do that (even though it worked on my tests). This is how it ended up:
[[ $1 =~ "^[0-9]+$" ]] && echo "number" && exit 0 || echo "not a number" && exit 1