Skip to content

Instantly share code, notes, and snippets.

@mattdanielbrown
Forked from earthgecko/is_integer
Created March 10, 2021 15:10
Show Gist options
  • Save mattdanielbrown/696282211e425492f073cb4c1c6c9334 to your computer and use it in GitHub Desktop.
Save mattdanielbrown/696282211e425492f073cb4c1c6c9334 to your computer and use it in GitHub Desktop.
is_integer
function is_integer () {
# exit code 0 - the string is an integer
# exit code 1 - the string is not an integer
local string=$1
[[ $string == ${string//[^0-9]/} ]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment