If your system implementsOn systems that implement procfs interface such as Linux, you can just check if there is a special file /proc/$PID/status exists:
if [test -ed /proc/$PID"$PID"/status ];; then echo "process exists" fi otherwise you can use ps program:
if [ -n "$(ps -p $PID -o pid=)" ] In the latter form, -o pid= is an output format to display only the process ID column with no header. The quotes are necessary for non-empty string operator -n to give valid result.