5

How can I suspend a whole command sequence in bash or zsh (or maybe some other shell)?

For example, if I run:

sleep 100; echo foo

and press Ctrl + Z, sleep is suspended and put into background, but echo then runs immediately.

I would like the latter not to happen, i.e. echo should run after sleep was resumed and completed.

1 Answer 1

6

Execute them from subshell:

( sleep 100 ; echo foo ; )

And ctrl+z will freeze whole subshell, not just one command:

^Z
[1]+  Stopped                 ( sleep 100; echo foo ; )

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .