Bash: -x / execution tracing
14 December 2025 (Updated 14 December 2025)
Turn on execution tracing for entire script
Use the -x option to turn on shell tracing so that variable values are shown when you execute the script.
#!/bin/bash
set -x
# Your code...
Turn on execution tracing for a specific portion
#!/bin/bash
set -eou pipefail
name=sajad
set -x # Enable execution tracing
echo "$name"
set +x set -x # Disable execution tracing
hostname
Tagged:
Bash