Bash-common-checks: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
===Common checks and validations that are a PITA to remember=== | ===Common checks and validations that are a PITA to remember=== | ||
====Is Integer?==== | |||
* Check if a var is an integer | * Check if a var is an integer | ||
* support negative as well as positive integer values using extended regex | * support negative as well as positive integer values using extended regex |
Revision as of 12:21, 19 October 2021
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