0

I'm trying to create an alias in my .bash_profile so if I run it it will kill any app that I choose.

What I've done:

alias terminate='ps -ax | grep '

If I run terminate App, returns list of App ID, so then I do kill + App ID and it's done.

Now, if that App has many ID's it's a pain in the ass to have to do kill + ID for each ID.

Apparently, if I do kill -9 $(ps -ax | grep App), it kills the entire App. (What I do is kill -9 $(terminate App))

Now I want to create another alias, as fullkill, so if I run fullkill App it would do the same.

What I've tried:

alias fullkill='kill -9 $(ps -ax | grep )'

Run:

fullkill App

Returns

- bash: kill: App: arguments must be process or job IDs
kvantour
  • 25,269
  • 4
  • 47
  • 72
pyseo
  • 431
  • 1
  • 6
  • 11
  • 1
    `kill "$(pgrep "name")"` or if you want to kill some scripts `kill "$(pgrep -f "name")"` or even better `pkill "name"` – kvantour Feb 05 '20 at 12:26
  • 2
    You could use `pkill` [Docs](https://ss64.com/osx/pkill.html) – 0stone0 Feb 05 '20 at 12:27
  • 2
    Does this answer your question? [How can I kill a process by name instead of PID?](https://stackoverflow.com/questions/160924/how-can-i-kill-a-process-by-name-instead-of-pid) in combination with [Make a Bash alias that takes a parameter](https://stackoverflow.com/questions/7131670/) – kvantour Feb 05 '20 at 12:27
  • 2
    Don't use `kill -9` routinely. You should send trappable signal like 15 or 2, and only then if the program is too buggy or too hung escalate to the thermonuclear option. – tripleee Feb 05 '20 at 12:41

0 Answers0