How to output return code in shell? December 23, 2023 by Tarik echo $? >> /path/to/return_code $? has the return code of the last statement in bash.