How to successfully debug a shell Script | Sedulity Groups

Debugging a shell script is very essential to check your script for any errors. There are different debugging tips and tricks useful for running your scripts
without any flaw.
  • -x if you set this option, it will show you each
    line before it executes it. Comments will not be reported.
For example: sh –x scriptname
  • -v Echo’s each line as it is read. It’s a kind
    of verbose and even echo back commented lines too.
Example: sh –v scriptname
Note: A small difference between –x and –v is
that –v echo’s the line as it is read (So it will even
display comments too.), whereas –x flag causes each command to be
echoed as it is executed.

For Example: sh –xv scriptname

Example: sh –e scriptname