Syntax

Bash Exit Status Syntax

In Bash, exit status: gets the exit code of the last command — echo $?

Quick Answer

Syntax
echo $?
BashSyntax

Exit Status

Code example
echo $?

Gets the exit code of the last command.

Learn More

How to exit status in Bash

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

Bash Exit Status Syntax

Use echo $?.

Related Syntax References

Frequently asked questions

What is the Bash syntax for exit status?

Use this pattern: echo $?

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