I have a program that takes arguments. I want to enforce that the arguments are integers. This is how I've been doing it.
allowed='^[0-9]+$'
if [[ $1 =~ $allowed ]]; then
echo "number"
else
echo "not a number"
fi
The problem with this is that it doesn't allow negative numbers because the dash at the beginning isn't a digit. How would I re-do the regex expression so that it allows negative numbers?