bash -x
Tracing mode, turned on with bash -x or set -x, in which bash prints each command after expansion, just before running it.
In more detail
Each trace line starts with a plus sign, one per level of nesting, and shows the real values the command received, which exposes typos and bad quoting. Wrap only the suspect part in set -x and set +x to keep the output short. Trace output goes to standard error.
Example
bash -x script.shRelated terms
- PS4 — The bash variable that sets the prefix printed before each line of set -x trace output, a plus sign and a space by default.
- bash -n — Running bash with -n, which reads and parses a script but runs nothing, reporting syntax errors only.
- set builtin — The builtin that turns shell options on with a minus sign and off with a plus sign, such as set -e and set +x.
Taught in
- Debugging: set -x, bash -n And Reading The Error — Bash Scripting & Command Line Automation