When running a command in bash it will store the return code in the special variable $?, like this:

[robin@book robin]$ ls -ld tmp
drwxr-xr-x  3 robin  robin  1024 Aug  3 11:02 tmp
[robin@book robin]$ echo $?
0
[robin@book robin]$ ls -ld bob
ls: bob: No such file or directory
[robin@book robin]$ echo $?
1
[robin@book robin]$

When running a series of commands in a pipe however it is sometimes necerssary to find the return code of an individual command in the pipe, in this case bash stores the return codes in an array names $PIPESTATUS which you can access like any other bash array. The array can only be used once however, so if you want to use it more than once store it in some other temporary array.

[robin@book robin]$ echo "tmp"  | xargs ls -ld
drwxr-xr-x  3 robin  robin  1024 Aug  3 11:02 tmp
[robin@book robin]$ echo ${PIPESTATUS[@]}
0 0
[robin@book robin]$ echo "bob"  | xargs ls -ld
ls: bob: No such file or directory
[robin@book robin]$ echo ${PIPESTATUS[@]}
0 1
[robin@book robin]$ echo "bob"  | xargs ls -ld
ls: bob: No such file or directory
[robin@book robin]$ echo ${PIPESTATUS[1]}
1
[robin@book robin]$