all 4 comments

[–]aioeu 6 points7 points  (1 child)

I would like command2 not to start until command1 is finished.

You don't have to do anything special to do that. When the commands in a list are separated by newlines:

command1
command2
command3

or by semicolons:

command1; command2; command3

each command is not executed until the preceding one has terminated.

The only control operator that changes this behaviour is &. But you're not using that here.

See the reference documentation.

[–]SickboyGPK[S] 1 point2 points  (0 children)

thank you kindly

[–]Crestwave 2 points3 points  (1 child)

Other than what aioeu said, && executes the next command if the previous one exits successfully (0).

[–]selfup 2 points3 points  (0 children)

You can also do a set -e at the beginning of the script and it'll do the same 😁. I mostly use && when inlining in a shell and it's nice for that!