Bash-common-checks
Jump to navigation
Jump to search
Common checks and validations that are a PITA to remember
Is Integer?
- Check if a var is an integer
- support negative as well as positive integer values using extended regex
VAR=123
if [[ ${VAR} =~ ^-?[0-9]+$ ]]; then
echo "Is integer"
else
echo "Is not integer"
fi