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:
echo $?
Output:
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):
date
echo $?
Output:
Sat Sep 10 11:18:59 EDT 2022
0
And this will return 1
because running false returns it like an error would
false
echo $?
Output:
1
-- end of line --