How/Command to check the previously executed command’s status(success or not) – Unix/Linux

In some strange situations it would be more helpful for us to find the previously executed command’s status(success or not). We can figure it out by using the following command;

# echo $?

Output:

0 : The '0' represents, successfully executed command status. :-)
Any other digit : represents, the previously executed command was failed. :-(

Example:

----
[[email protected] ~]# gdgmd
bash: gdgmd: command not found
[[email protected] ~]# echo $?
127
----
[[email protected] ~]# man ls
[[email protected] ~]# echo $?
0
----

Related Links:
echo $SHELL

Post navigation

Arunlal Ashok

Linux Systems Architect at Endurance International Group. I know her (Linux) since many years. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com

Leave a Reply

Your email address will not be published. Required fields are marked *