How can I get the exit code in a bash script? I'm using if [ $? -eq 0 ] then echo "Everything is O.K." else # want to get exit code here fi