stow_dotfiles/scripts/.local/bin/getpid
2024-11-21 15:20:16 -05:00

15 lines
246 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
if [ $# -eq 0 ]; then
echo "Error: No arguments provided."
echo "Usage: getpid <name_of_process>"
exit 1
fi
srch="$1"
ps -ef | awk -v this="$0" -v search="$srch" '{
if($NF~search && $0!~this){print $2}
}'