LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-04-2010, 09:21 PM   #1
vinothaa
LQ Newbie
 
Registered: Feb 2009
Posts: 13

Rep: Reputation: 0
Question echo command


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


regards
vinoth
 
Old 06-04-2010, 09:26 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
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.
 
Old 06-04-2010, 09:28 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
this sounds like homework
look at " man echo " or search google/linux http://www.google.com/linux
 
Old 06-04-2010, 10:47 PM   #4
jim.yefeng
LQ Newbie
 
Registered: Jun 2010
Posts: 6

Rep: Reputation: 0
Shell uses negative logic.
In general, $? equals 0 denotes the execution of previous command is successful.
 
Old 06-05-2010, 07:24 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Quote:
Originally Posted by jim.yefeng View Post
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.
 
Old 06-05-2010, 08:15 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
echo command mohit_parihar Linux - General 3 01-12-2010 06:54 AM
Command echo Corrado Linux - Newbie 3 11-11-2009 06:44 PM
more information about echo command shuchi Linux - Newbie 9 04-18-2009 06:15 AM
echo: command or built-in? colucix Linux - General 5 01-06-2008 11:55 AM
echo command s_hcl Linux - General 1 09-06-2006 05:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration