Ole Ole - 9 months ago 33
Linux Question

What does `set -x` do?

I have a shell script with the following line in it:

[ "$DEBUG" == 'true' ] && set -x

Answer Source

set -x enables a mode of the shell where all executed commands are printed to the terminal. In your case it's clearly used for debugging, which is a typical use case for set -x: printing every command as it is executed may help you to visualize the control flow of the script if it is not functioning as expected.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download