$? 환경변수 사용. Unix / Linux Bourne / Bash Shell Scripting Tutorial 참조.# 프로그램 실행.
if [ "$?" -ne "0" ]; then
echo "Sorry, cannot find user ${1} in /etc/passwd"
exit 1
fi
# PIPESTATUS에 배열로 들어가며, 최초 명령의 Exit code는 PIPESTATUS[0]에 들어간다.
<command> | tee out.txt
test ${PIPESTATUS[0]} -eq 0