I run the following code unsuccessfully
sudo killall %4
where %4 is my Vim session.
How can you terminate a job without foregrounding it?
I run the following code unsuccessfully
sudo killall %4
where %4 is my Vim session.
How can you terminate a job without foregrounding it?
Try kill %4
instead. The unix shell uses %x as variables for currently running processes. To see the processes you can use with the %x syntax, use jobs
. Killall is a wrapper around "kill" that is basically the equivalent of `ps -aux | grep | cut -f2 -d " " | xargs kill' or the like if you're a shell junky.
No, sorry, that shell command won't quite work, but it does illustrate how killall works =p. It simply kills every process it can that matches the string you provide.
Also, try `man kill' to learn more about kill. Particularly, kill -9 you may find useful. It's sorta the equivalent of 'force quit'.
I believe you want "kill" instead of "killall". I tested under tcsh like this:
home% cat
^Z
Suspended
home% kill %1
home%
[1] Terminated cat
Furthermore, I doubt this would work with sudo because sudo would invoke a new shell, wouldn't it? And in that shell, %4 would not be defined.
home% cat
^Z
Suspended
home% sudo kill %1
Password:
kill: illegal process id: %1
If you really need to sudo, you can try this:
home% jobs -l
[1] + 26318 Suspended cat
home% sudo kill 26318