LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   echo command (https://www.linuxquestions.org/questions/linux-newbie-8/echo-command-812243/)

vinothaa 06-04-2010 09:21 PM

echo command
 
this is vinoth. what is the use of echo $? in redhat linux.pls explain it.


regards
vinoth

AlucardZero 06-04-2010 09:26 PM

it returns the exit status of the most recent command run.

you should look up some beginner's books for Linux and shell scripting and read them.

John VV 06-04-2010 09:28 PM

this sounds like homework
look at " man echo " or search google/linux http://www.google.com/linux

jim.yefeng 06-04-2010 10:47 PM

Shell uses negative logic.
In general, $? equals 0 denotes the execution of previous command is successful.

timmeke 06-05-2010 07:24 AM

Quote:

Originally Posted by jim.yefeng (Post 3993007)
Shell uses negative logic.
In general, $? equals 0 denotes the execution of previous command is successful.

The meaning of the exit code 0 can vary depending on the application. By convention, 0 means successful run. This is a convention of app developers more than it is "built in" logic of the shell.

druuna 06-05-2010 08:15 AM

Hi,

In addition to timmeke's reply: Not 0 doesn't necessarily mean the program ran unsuccessful.

Example: Grep can return 1, that tells you grep did not find the pattern given. Which could be what you wanted....

Always look at the manual page/documentation to find out where these numbers stand for.


All times are GMT -5. The time now is 08:10 PM.