Bash – Debugging shell scripts: Syntax checking without executing

bashshell-scripttesting

Is there some option I can give to just check the syntax of a [bash] shell script to check the syntax of it, but not actually execute anything nor cause any potential damage?

Best Answer

From the bash(1) man page:

-n      Read commands but do not execute them. This may be used to check a
        shell script for syntax errors. This is ignored by interactive shells.
Related Question