Created
January 8, 2014 20:56
-
-
Save coderofsalvation/8324521 to your computer and use it in GitHub Desktop.
check if port is a num and if it's privated (<1025), returns 0 on success, 1 otherwise (bashfunction)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check if port is a num and if it's privated (<1025), returns 0 on success, 1 otherwise | |
# @param int portnumber | |
function isprivport() | |
{ | |
[ -z "$1" ] && return 1 | |
printf "%s\\n" "$1" | grep -v "[^0-9]" >/dev/null | |
if [ $? -eq 0 ]; then | |
[ $1 -gt 0 ] && [ $1 -lt 1025 ] && return 0 || return 1 | |
else | |
return 1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment