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
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
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 $?
     0
     $ [ 1 = 2 ] ; echo $?
     1

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