I am trying to execute a program which loops indefinitely, and so must be forcibly interrupted. After executing the program, I want to delete it. I can do it in several steps:
- Control + C
but I need to do this often, so I'd like to have steps 1 and 3 on a single line for easy history recall.
I have tried the following, but in each case the Control + C interrupt kills the whole line, not just the executing program, and so the file is never deleted:
./MyProg && rm MyProg ./MyProg; rm MyProg ./MyProg || rm MyProg
How can I get the interrupt to affect only the running program, and not the whole command line?