Bash-common-checks: Difference between revisions

From I Will Fear No Evil
Jump to navigation Jump to search
(Created page with "## Common checks and validations that are a PITA to remember ## * Check if a var is an integer <pre> VAR=123 if [[ ${VAR} =~ ^-?[0-9]+$ ]]; then echo "Is integer" else ech...")
 
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#
* Check if a var is an integer
* Check if a var is an integer
<pre>
<pre>

Revision as of 09:28, 19 October 2021

  1. Common checks and validations that are a PITA to remember#
  • Check if a var is an integer
VAR=123
if [[ ${VAR} =~ ^-?[0-9]+$ ]]; then
  echo "Is integer"
else
  echo "Is not integer"
fi