On systems that implement procfs interface such as Linux, you can just check if /proc/$PID exists:
if test -d /proc/"$PID"/; 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.