Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Find Exit Code of Last Command Run On The Command Line

This is how you find the exist code of the last command you ran:

Code

echo $?

Results

0

A `0` is returned if there were no problems. Any non-0 value represents an error.

For example, this will return `0` (assuming `date` runs properly):

Code

date
echo $?

Results

Sat Sep 10 11:18:59 EDT 2022
0

And this will return `1` because running false returns it like an error would

Code

false
echo $?

Results

1

References