Bash help requested: Capturing command errors within pipes

Daniel B. Thurman dant at cdkkt.com
Thu Mar 19 17:22:07 UTC 2009


I have been trying to capture bash pipe errors as follows:

ret1=0; ret2=0; ret3=0; ret4=0; ret5=0

out=$(\
grep "PATTERN" "${SFILE}"; ret1=$? 2>&1 | \
sed $re1 $re2; ret2=$? 2>&1 | \
sort -n; ret3=$? 2>&1 | \
uniq >> "${TFILE}"; ret4=$? 2>&1\
); ret5=$?

But the return status variables are not changed
should any command errors arise.

How could one go about capturing command errors within pipes?

Thanks!
Dan




More information about the users mailing list