Skip to content

Instantly share code, notes, and snippets.

@mmasashi
Created September 17, 2015 05:38
Show Gist options
  • Save mmasashi/83453e3c896b612e950a to your computer and use it in GitHub Desktop.
Save mmasashi/83453e3c896b612e950a to your computer and use it in GitHub Desktop.
Validate number for argument value (Bash)
#!/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