Debugging a bash script with -x

suggest change

Use “-x” to enable debug output of executed lines. It can be run on an entire session or script, or enabled programmatically within a script.

Run a script with debug output enabled:

$ bash -x


$ bash --debug

Turn on debugging within a bash script. It may optionally be turned back on, though debug output is automatically reset when the script exits.

set -x   # Enable debugging
# some code here
set +x   # Disable debugging output.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents