Question:
What does $? return?
Answer:
Will return the status of the command which is executed lastly. 0 => Success 2 => Error Source: CoolInterview.com
$? ---> will give the exit status of last background process
ZERO for sucess. NON-ZERO for unsuccess Source: CoolInterview.com
Answered by: Amaresh Chandra Das | Date: 12/28/2007
| Contact Amaresh Chandra Das
it checks the exit status of last executed command
It also print the return value of a function. Source: CoolInterview.com
Answered by: pritish | Date: 9/2/2008
| Contact pritish
$? gives the Exit status of the last backgroud process running in the system. 0-->success 1-->error 2-->warning Source: CoolInterview.com
Answered by: sailabala sahoo | Date: 12/29/2009
| Contact sailabala sahoo
$? will have the return code or return status of the previous command.
Ex: At the time of running the SQL queries, we can perform the Commit or Rollback based on the value of the Variable $?.
Value=$?
if [[ $Value == 0 ]] then db2 "commit" else db2 "rollback" fi Source: CoolInterview.com
Answered by: Kuppusamy | Date: 1/4/2010
| Contact Kuppusamy
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|