Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Debian GNU/Linux Reference Guide
Prev Home Next

4.3.9 Return value of the command

Each command returns its exit status as the return value.

  • return value = 0 if the command executes successfully.

  • return value = non-zero if the command exits with error.

This return value can be accessed by the $? shell variable immediately after the execution.

     $ [ 1 = 1 ] ; echo $?
     $ [ 1 = 2 ] ; echo $?

Please note that, when the return value is used in the logical context for the shell, success is treated as the logical TRUE. This is somewhat non-intuitive since success bears value zero.

See Shell conditionals, Section 13.2.5.

Debian GNU/Linux Reference Guide
Prev Home Next

  Published under the terms of the GNU General Public License Design by Interspire