Skip to content

Instantly share code, notes, and snippets.

@EvilJordan
Created July 30, 2025 23:13
Show Gist options
  • Select an option

  • Save EvilJordan/ef8135a37b82a79a6e9dab1c5e5d9198 to your computer and use it in GitHub Desktop.

Select an option

Save EvilJordan/ef8135a37b82a79a6e9dab1c5e5d9198 to your computer and use it in GitHub Desktop.
MURDER (kill all processes sharing a common name passed as a CLI parameter)
#!/bin/bash
murder() {
if [[ -z $1 ]]; then
echo "Missing argument!"
return
fi
echo "Killing $1..."
PROCESSES=`ps -ax | grep $1 | grep -v grep`
if [[ -z $PROCESSES ]]; then
echo "Nothing to kill!"
return
fi
PROCESSESARRAY=()
while IFS= read -r line; do
PROCESSESARRAY+=("$line")
done <<<"$PROCESSES"
for PROCESS in "${PROCESSESARRAY[@]}"; do
THISPID=`echo $PROCESS | grep -oEm 1 "^[0-9]+"`
echo "Killing PID: $THISPID"
sudo kill $THISPID
done
echo "done."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment