bash -n

Running bash with -n, which reads and parses a script but runs nothing, reporting syntax errors only.

In more detail

It is safe even on a script you do not trust or that deletes files, because no command executes. It cannot find mistakes that only show up at run time, such as a misspelled command.

Example

bash -n broken.sh

Related terms

Taught in

References