Created
September 17, 2015 05:38
-
-
Save mmasashi/83453e3c896b612e950a to your computer and use it in GitHub Desktop.
Validate number for argument value (Bash)
This file contains 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
#!/bin/bash | |
pid=$(expr "$1" : '\([0-9][0-9]*\)') | |
if [ "$1" = "" ] || [ "$1" != "$pid" ]; then | |
echo "pid requires to be given" | |
exit 1 | |
fi | |
echo $pid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment