como aprobar si es numero en bash 1

como aprobar si es numero en bash

re='^[0-9]+$'
if ! [[ $yournumber =~ $re ]] ; then
   echo "error: Not a number" >&2; exit 1
fi

Here is what the above code is Doing:
1. It’s checking if the input is a number.
2. If it’s not a number, it’s printing an error message and exiting the program.
3. If it is a number, it’s printing a message saying that it’s a number.

Similar Posts