et (
http://stackoverflow.com/questions/90418/exit-shell-script-based-on-process-exit-code) :
"" After each command, the exit code can be found in the $? variable so you would have something like:
ls -al file.ext
rc=$?
if [[ $rc != 0 ]] ; then
exit $rc
fi
You need to be careful of piped commands since the $? only gives you the return code of the last element in the pipe so, in the code:
ls -al file.ext | sed 's/^/xx: /"
will not return an error code if the file doesn't exist (since the sed part of the pipeline actually works, returning 0).""