From a32adb208050048c68e68c03d89eac346afa9757 Mon Sep 17 00:00:00 2001 From: Matan Horovitz Date: Sun, 10 Apr 2022 09:52:35 +0300 Subject: [PATCH] Add ability to use process name --- Donnagurai | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Donnagurai b/Donnagurai index 9f0fa8c..cf9e0fc 100755 --- a/Donnagurai +++ b/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