Displaying the status code of the last executed command in the terminal
Published on 2023-10-21 • Modified on 2023-10-21
This snippet shows how to display the status code of the last executed command in the terminal. It can be helpful in shell scripts but also when the command output is unclear.
echo "test exit code, it should be 0"
# Bash
echo $?
0
# If using the fish shell, the previsous command doen't work and you have to use
# the following command:
echo $status
0
More on Stackoverflow Read the doc Random snippet
Call to action
Did you like this post? You can help me back in several ways: (use the "reply" link on the right to comment or to contact me )
- Report any error/typo.
- Report something that could be improved.
- Like and repost!
- Follow me on Bluesky 🦋
- Subscribe to the RSS feed.
- Click on the More on Stackoverflow buttons to make me win "Announcer" badges 🏅.
Thank you for reading! And see you soon on Strangebuzz! 😉
