(888) 685-3101 ext. 2

Often enough I have to mess around with shell scripts and even more often I have to spend a considerable amount of time debugging scripts. Though whenever I find myself having to debug a script I often use this little bit of code to help me step through my code to find my problem. I simply enter the below into the script before the code that I’m having an issue with and it lets me see the input/output of each command and doesn’t continue to the next part of the script until I press enter.

#!/bin/bash
set -x
trap read debug
<mycode>

Without this I would most likely spend even more time debugging scripts. Hopefully someone else finds this little snipet useful while debugging their scripts.

Share This