This is the biggest help when trying to figure out what or why a bash script is doing what it is doing. This trick will allow you to see all command expansions and dump them to stdout (effectively taking any guesswork out)
Add set -x before you want to start expanding all commands
(optionally) add set +x to not expand commands that follow
Run your script with -x: $ bash -x <script>
If you want to stop executing your script when a command returns a non-zero exit code, this is an effective way to see what is failing
Add set -e when you want this behavior to take effect
Run your script with -e: $ bash -e <script>