Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I have a long shell script containing a lot of conditions and I want to know whether there is any syntax error in the script without running it.

Since shell script is interpreted I think it is not possible but is there a way to know by using some trick.

share|improve this question
up vote 29 down vote accepted
bash -n scriptname

Although, this will check syntax, not command availability. (will not warn if script uses a command that is not installed yet)

share|improve this answer
In addition to bash's inbuilt syntax checḱing you can use shellcheck to identify less severe issues and bad practices. – Glutanimate Jun 15 '14 at 22:40

I found an online tool to check the syntax of the script. In addition to checking the script, also suggests possible corrections to avoid errors.

Check shell script online

share|improve this answer

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.