Syntax

Bash Debug a Script Syntax

In Bash, debug a script: prints each command before it runs — set -x

Quick Answer

Syntax
set -x
BashSyntax

Debug a Script

Code example
set -x

Prints each command before it runs.

Learn More

How to debug a script in Bash

  1. Open your Bash file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Bash Debug a Script Syntax

Use set -x.

Related Syntax References

Frequently asked questions

What is the Bash syntax for debug a script?

Use this pattern: set -x

Can I copy this Bash code example?

Yes. Use Copy code and adapt the example to your program.

Is this Bash syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify