Advertisement
pintcat

term - Kills processes by their names

Dec 17th, 2024 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.34 KB | Software | 0 0
  1. #!/bin/sh
  2. # term v1.0 - Kills processes by their names. If several processes use the same name they're all gonna be terminated.
  3.  
  4. if [ -z "$1" ]; then
  5.     ps -e
  6.     exit
  7. else
  8.     PID=$(ps -e | grep $1 | awk -F ' ' '{print $1}')
  9. fi
  10. if [ -z "$PID" ]; then
  11.     echo $1": No active process with that name."
  12.     exit 1
  13. fi
  14. for NUM in $PID; do
  15.     kill $NUM
  16. done
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement