Add ability to use process name
This commit is contained in:
12
Donnagurai
12
Donnagurai
@@ -37,6 +37,18 @@ flags()
|
||||
if [[ $1 =~ ^[0-9].*$ ]]; then
|
||||
PIDS+=("$1")
|
||||
export PIDS
|
||||
elif [[ $1 =~ ^[a-z].*$ ]]; then
|
||||
procs=$(ps aux | grep $1 | grep -v grep | grep -v "$(pwdx $$ | awk '{print $NF}')")
|
||||
# exclude the path of the current script PID ^
|
||||
if [[ -n "$procs" ]]; then
|
||||
for proc in "$procs"; do
|
||||
proc_pid=$(echo "$proc" | awk '{print $2}' | grep -v "$(pwdx $$)")
|
||||
if [[ -n $(ps aux | grep "$proc_pid") ]]; then
|
||||
PIDS+=("$proc_pid")
|
||||
export PIDS
|
||||
fi
|
||||
done
|
||||
fi
|
||||
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
|
||||
help
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user