[CentOS] Getting the return value of the last command run
Bob Beers
bob.beers at gmail.com
Mon May 30 14:55:41 UTC 2011
On Mon, May 30, 2011 at 10:38 AM, Dotan Cohen <dotancohen at gmail.com> wrote:
> All commands return a value, usually 0 if run properly. For instance, try:
> $ ls && echo "done"
> $ lsd && echo "done"
>
> The echo command is only executed if the ls command exited
> successfully. If one did not add the echo command with the && after a
> command, how can he determine if the command exited successfully?
You can check the return code.
$ ls
$ echo $?
0 (usually) indicates success.
- Bob
More information about the CentOS
mailing list