As help set
says:
-x Print commands and their arguments as they are executed.
It works both in interactive and non-interactive shells, so you can try running set -x
in an interactive shell to see the effect. Each command that is run is echoed to you first (with +
signs in front of them to help you distinguish them from most regular output).
ek@Cord:~$ echo hello world
+ echo hello world
hello world
(If you see way more output than you expect an an interactive shell, your shell may be running commands to build your prompt. For example, you'll see about twenty additional lines if your prompt is set up to show information about the git repository you're navigated to, even if you're not actually in a repo now.)
To turn it off run set +x
. Somewhat confusingly, with set
, -
enables a shell option and +
disables it.
For more information, see 4.3.1 The Set Builtin in the Bash reference manual.
man bash
? Despite of that: https://unix.stackexchange.com/questions/409366/what-is-bash-x https://stackoverflow.com/questions/64110936/bash-x-or-set-x https://linuxtect.com/what-does-bash-set-x-do/ – U. Windl Feb 15 '23 at 23:31