The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 09-28-2005
diganta diganta is offline
Registered User
  
 

Join Date: Dec 2004
Location: India, Bangalore
Posts: 18
Problem with exit status

Hi,

Consider the output of the following commands:

case1)
-------
# ifconfig -a | grep "UP" | grep uplink0:1
# echo $?

Output is: 0

case2
------
# ifconfig -a | grep "UP" | grep uplink0:1; echo $?

Output is: 1

In case2 we got the exit code as 1, which is the actual exit code.
Why did we not get the actual exit code in case1?

What is the difference between executing two different command at the same time (as in case 2) and one after the other (as in case 1)? In both the cases the commands will get executed in the same sequence.

Any help will be highly appreciated.

Thanks.