3 USAGE
="usage: ./process-pid.sh {[-h, -a], [-f, -e] <pid>}, -s <regexp>"
6 if [[ "$1" -eq "-h" ]]; then
10 elif [[ "$1" =~ ^
-?
[0-9]+$
]]; then
11 if `ps $1 > /dev/null 2>&1`; then
12 echo "you win!"; exit 0
15 echo -ne "invalid pid\n$USAGE"; exit 1
19 elif [[ "$1" -eq "-e" && "$2" =~ ^
-?
[0-9]+$
]]; then
20 if `ps $2 > /dev/null 2>&1`; then
21 echo "you win!"; exit 0;
24 echo -ne "invalid pid\n$USAGE"; exit 1
26 # -s <pid> <regex> case
27 elif [[ "$1" -eq "-s" && "$2" =~ ^
-?
[0-9]+$
]]; then
28 if `ps $2 > /dev/null 2>&1`; then
29 echo "you win!"; exit 0;
32 echo -ne "invalid pid\n$USAGE"; exit 1