Today I Learned

hashrocket A Hashrocket project

Referencing jobs (to kill them)

Generally I've killed processes by pid, like kill -9 30452, but that involves looking up the pid. If your shell started the job you can reference the process by its job id %number.

> cat &
[1] 70058
[1]  + suspended (tty input)  cat
> kill %1
[1]  + terminated  cat

Or you can reference it by name %name

> cat &
[1] 70064
[1]  + suspended (tty input)  cat
> kill %cat
[1]  + terminated  cat

Killing processes in this way surprisingly only works on the last started job.

> cat & ; cat &
[1] 70110
[2] 70111
[2]  + suspended (tty input)  cat
[1]  + suspended (tty input)  cat
> kill %cat
[2]  - terminated  cat
> jobs -l
[1]  + 70110 suspended (tty input)  cat
See More #command-line TILs