Skip to content

Instantly share code, notes, and snippets.

@santaklouse
Created June 4, 2022 21:09
Show Gist options
  • Select an option

  • Save santaklouse/03fa8f5c67fa44ae7a420abaab2c8be1 to your computer and use it in GitHub Desktop.

Select an option

Save santaklouse/03fa8f5c67fa44ae7a420abaab2c8be1 to your computer and use it in GitHub Desktop.
get pids of process names
function pidsof() {
pids=(`pgrep "$1"`, `pidof "$1"`, `ps -Ac | grep -m1 '"$1"\$' | awk '{print \$1}'`)
pids=$piods|tr ',' ' '
echo pids
#
# strings=(`pgrep "$a"`, `pidof "$a"`, `ps -Ac | grep -m1 '"$a"\$' | awk '{print \$1}'`)
#
# pids=()
# for i in "${!strings[@]}" ; do
# #echo "${strings[$i]}"
# cmd="${strings[$i]/ARG/"$a"}";
# #echo "$cmd"
# pids+="$(echo $cmd)"|tr ',' '\n';
# echo $(echo $cmd|tr ',' '\n')
#
# done
#
#
#
# pids=($pids)
#
# echo $pids
# echo ${pids[@]}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment