I have been reading this solution: https://stackoverflow.com/a/35587710 for the case when you have executed a program with a long execution time and just after that you realize you wanted to execute another program when the first one finish. The solution says use:
Ctrl Z
fg ; python next_program.py
If what I wanted to execute was badly written due to a typo, i.e., I wrote fg ; python my_prograM.py
and I wanted to do fg ; python my_program.py
, how can I cancel the first fg and launch the second one? Thanks.
Your original job is still the one that Ctrl-Z would interrupt, and the one that fg
will resume. Just interrupt as you did before, then type fg; python my_program.py
to fix the typo. fg
only restarts the currently suspended job; it doesn't repeat the last shell command line.