- set -x
Adding "set -x" in the script, it enables the printing of command traces before executing command. This is equivalent to the long command notation:
- set -o xtrace
However, there are cases that you cannot modify the bash script itself because of permission or you simply don't want to modify the file. Then there is another option:
$ bash -x myscript.sh
This will allow you to execute the script with command traces which are good for debugging.