Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

How to perform syntax check on a bash script?

Answer:

You can perform syntax check on a bash script, without actually running it using the following command:

# bash -n script.sh

But if your script contain execution of other program, bash will not try to run it, even if it does not exist, error of this type will not be returned.

  1. How to perform syntax check for Python program
  2. How to perform syntax check for Perl program
  3. Perform syntax check to PHP files
  4. How to get the PID in current bash shell script
  5. Check if a file exist in Bash Shell

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>