#!/bin/sh # Usage: pidof if [ -z "$1" ]; then echo "Usage: $0 " exit 1 fi # Find PIDs for exact match PIDS=$(pgrep -x "$1") if [ -n "$PIDS" ]; then echo $PIDS | tr '\n' ' ' echo "" # Add newline at end else exit 1 # No process found fi