Unix & Linux Forums

Unix & Linux Forums (http://www.unix.com/index.php)
-   Shell Programming and Scripting (http://www.unix.com/shell-programming-and-scripting/)
-   -   return code of a unix command (http://www.unix.com/shell-programming-and-scripting/41055-return-code-unix-command.html)

ramky79 08-02-2007 04:15 PM

return code of a unix command
How to find out whether the command I executed is successful or unsuccessful(at commandlinet)

say i execute the following command at command line
rm *
How do i find out whether my previous command is a success or failure.


Best Regards,

jim mcnamara 08-02-2007 04:34 PM

Note: rm * can be very dangerous, be careful


<some command>
echo "$?"

will display 0 if "some command" was successful. It will show 1 (or another non-zero number) if the command failed. Usually commands also display error messages when something goes wrong.

All times are GMT -4. The time now is 05:16 AM.

Linux and Unix Supported by: vBulletin
Search Engine Optimisation provided by DragonByte SEO v1.1.4 (Pro) - vBulletin Mods & Addons Copyright © 2015 DragonByte Technologies Ltd.
Unix & Linux Forums Content Copyright ©1993-2015. All Rights Reserved.
Forum Operations by The UNIX and Linux Forums