Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 6 down vote accepted

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.
share|improve this answer
Obviously. I don’t know why I was so blind that I couldn’t see this when I was through the manual pages. – Aeyoun May 25 '11 at 21:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.