Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run one command after another, even if I suspend the first one (Ctrl-z)

I know in bash I can run one command after another by separating them by semicolons, like

$ command1; command2 

Or if I only want command2 to run only if command1 succeeds, using &&:

$ command1 && command2 

This works, but if I suspend command1 using Ctrl-z, in the first case, it runs command2 immediately, and in the second case, it doesn't run it at all. How can I run commands in sequence, but still be able to suspend the first command, but not have the second run until I have restarted it (with fg) and it finishes? I'd prefer something as simple to type as possible, as I would like to do this interactively. Or maybe I just need to set an option somewhere.

By the way, what is the proper term for what Ctrl-z does?

like image 861
asmeurer Avatar asked Nov 28 '12 07:11

asmeurer


1 Answers

The following should do it:

(command1; command2) 

Note the added parentheses.

like image 180
NPE Avatar answered Oct 08 '22 13:10

NPE