How to make bash scripts print out every command before it executes?

bash -x script

or

set -x

in the script.

You can unset the option again with set +x. If you just want to do it for a few commands you can use a subshell: `(set -x; command1; command; …;)

Leave a Comment