Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there an equivalent of $! in ksh, which provides the error string ? $? stores the exit code only.

share|improve this question
up vote 2 down vote accepted

Unfortunately no. Generally in shell scripting, you can only get back information that the program passes to the environment, which on most unix systems is just the return code. Generally to find out what an error return value means, you will need to look in the manual page for the program which returned an error.

For example, the grep program will return a value of 1 if no lines are found to match, and a value of 0 (generally used for success) if there were lines found matching. A return value of 2 is used for an error. This is documented in the grep manpage

In many cases, the error will be printed on STDERR as well.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .