Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created January 8, 2014 20:58
Show Gist options
  • Save coderofsalvation/8324546 to your computer and use it in GitHub Desktop.
Save coderofsalvation/8324546 to your computer and use it in GitHub Desktop.
returns 0 if string is a number (bash function)
# returns 0 if string is a number
# @param string input
function isnumber()
{ #look for a number, returns 0 on success, 1 otherwise
[ -z "$1" ] && return 1
printf "%s\\n" "$@" | grep -v "[^0-9]" >/dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment