LinuxQuestions.org
Register a domain and help support LQ
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, 10: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, 10:26 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,808

Rep: Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604
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, 10:28 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,818

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
this sounds like homework
look at " man echo " or search google/linux http://www.google.com/linux
 
Old 06-04-2010, 11: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, 08: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, 09:15 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 07:54 AM
Command echo Corrado Linux - Newbie 3 11-11-2009 07:44 PM
more information about echo command shuchi Linux - Newbie 9 04-18-2009 07:15 AM
echo: command or built-in? colucix Linux - General 5 01-06-2008 12:55 PM
echo command s_hcl Linux - General 1 09-06-2006 06:27 AM


All times are GMT -5. The time now is 10:48 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration