Most shells provide functions like &&
and ;
to chain the execution of commands in certain ways. But what if a command is already running, can I still somehow add another command to be executed depending on the result of the first one?
Say I ran
$ /bin/myprog
some output...
but I really wanted /bin/myprog && /usr/bin/mycleanup
. I can't kill myprog
and restart everything because too much time would be lost. I can Ctrl+Z it and fg
/bg
if necessary. Does this allow me to chain in another command?
I'm mostly interested in bash, but answers for all common shells are welcome!