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 myscript.sh

Or

$ bash --debug myscript.sh

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

#!/bin/bash
set -x   # Enable debugging
# some code here
set +x   # Disable debugging output.

Feedback about page:

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



Table Of Contents