Introduction
Debugging helps find and fix mistakes in your script early. This saves you many hours of guesswork and frustration later.
When your script does not work as expected.
When you want to understand why a command fails.
When you want to check the values of variables during script run.
When you want to improve your script step-by-step.
When you want to avoid repeating the same mistakes.