Bash: Getting Error Code in the chain of Pipe

Submitted by admin on Tue, 11/08/2016 - 13:18

Use System Environment Variable${PIPESTATUS[X]}.
$ exit 1 | exit 2 | exit 3 | exit 0
$ echo ${PIPESTATUS[@]}
1 2 3 0

Also, the exit code of the normal end is 0, and the one of the abnormal end is Greater than 0 in Bash.

Tags