Bash: Run command after another

What many of you probably know is that you can chain commands together with the semicolon. Like so:

So here we’re running a unixbench, and then directly after, we’re appending “unixbench finished” to unixbench.log.

But what you might not know about is the ‘&&’ replacement for ‘;’. This will only do the next command if the first command returns 0, meaning clean finish.

And taking it a step further, there’s ‘||’ which does the opposite of ‘&&’. If the first command fails, then the next command happens.


Leave a Reply

Your email address will not be published. Required fields are marked *