Hi,

I am trying to get the exit status of the first command on the pipe,  
but I always get the exit status of the pipe reader.

     cat nofile; |sed -n '/abc/p'; echo "Error: $?"

I tried this, but didnt work to my requirement

     { cat nofile; err=$?; } |sed -n '/abc/p'; echo "Error: $err"

This is actually a simplified version of my requirement, any other  
method to accomplish this efficiently?

Two possible solution are
1. Find the exit status first by executing the cat command and then do  
the pipe again.
     Problem: I actually have a command in place of cat which takes  
long time and hence I can not execute it twice.

2. write the exit status to a file and use it further.
    Problem: some how I feel there is a better way of doing without  
writing the value to the disk.

Any other solutions.

Regards
-logu


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
linux-india-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-india-help

Reply via email to