15 lines
246 B
Bash
Executable file
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}
|
|
}'
|
|
|