Syntax

Bash Run If Previous Succeeds Syntax

In Bash, run if previous succeeds: runs the second command only on success (&&) or failure (||) — make && ./app cmd || echo "failed"

Quick Answer

Syntax
make && ./app cmd || echo "failed"
BashSyntax

Run If Previous Succeeds

Code example
make && ./app cmd || echo "failed"

Runs the second command only on success (&&) or failure (||).

Learn More

How to run if previous succeeds in Bash

  1. Open your Bash file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Bash Run If Previous Succeeds Syntax

Use make && ./app cmd || echo "failed".

Related Syntax References

Frequently asked questions

What is the Bash syntax for run if previous succeeds?

Use this pattern: make && ./app cmd || echo "failed"

Can I copy this Bash code example?

Yes. Use Copy code and adapt the example to your program.

Is this Bash syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify