I had a bash script which did the wrong thing. So I pressed Ctrl-C to stop it.

Is now the output I currently see on my terminal all the output produced by the processes that have run. Are does Ctrl-C also prevent output to be printed even though the process that wanted to output something has run/finished what it was doing.

So, I do:

for i in *; do rm -vf $i; done

Can I now be sure that all removed 'file' messages on my screen are those that are removed and nothing more has been removed?

Maybe relevant info: I worked in a screen session over ssh.

  • Please show what you did, and what happened. Then proofread, and re-write, so that it makes sense to someone that does not already know what you are asking. – ctrl-alt-delor Jul 25 '18 at 13:21
  • I gave a minimized example. Which parts do I need to clarify? – Hielke Walinga Jul 25 '18 at 13:53
  • I can not tell you what to show, as I have not seen it. But with your minimal example, show what you did, what you expected, and what happened. – ctrl-alt-delor Jul 25 '18 at 15:21

Essentially yes.

After the shell process catches your Ctrl-C interrupt, it stops it.

There are caveats however, such as in a for loop there can be a cmd that runs in the background.

Plus there are some cmds that run so quickly that you do not get a fast response from the shell (especially over a remote connection!) that it has or when it has actually received your "interruption" using Ctrl-C.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.