How do I kill the last spawned background task in Linux?
Example:
doSomething
doAnotherThing
doB &
doC
doD
#kill doB
????
There's a special variable for this in Bash:
kill $!
$! expands to the PID of the last process executed in the background.