I know how to kill the last process with  kill $!However I would like to kill the last−1 process, i.e. not the last one, but the one before the last one.I tried  kill $$(($! -1))but that didn't work. 
How to kill the (last - 1) PID with bash
bash;process;kill