Skip to content

Checking exit codes in bash

There are quite a few exit codes used on Linux systems, though no listing you can display when you’re feeling curious. In fact, you won’t see the numeric codes unless you specifically ask for them.

Instead, you will see a textual description of the problem you encountered—such as “No such file or directory”—in a context like this:

$ bin/runme
bash: bin/runme: No such file or directory

[ Get regularly scheduled insights by signing up for Network World newsletters. ]

If you want to see the numeric exit code, you can use the echo $? command. The error message will tell you that there is no “runme” script in your bin directory. The echo $? command will respond with only a number.

To read this article in full, please click here

Source:: Network World – Linux