UNIX & Linux Forums

UNIX & Linux Forums (https://www.unix.com/index.php)
-   Shell Programming and Scripting (https://www.unix.com/shell-programming-and-scripting/)
-   -   return code of a unix command (https://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 03:42 AM.

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