Debugging the Scripts
To debug the scripts when they fail to work correctly, do the following:
Add the following command in the beginning of each script:
set -x
This command will cause the script to display commands as they appear on the screen, which you can later analyze to identify the problem.