Shell Scripting - Debugging Shell Scripts

There are various ways of debugging shell scripts, i found these useful when debugging UNIX/LINUX related installer issues.


  1. Add the line set -vx in the beginning of the script. The shell script will then start debug output. You can disable the debug message by adding set +vx from that point onwards debug messages will be disabled
  2. Or doing sh -x shellscriptfilename (best option out the lot)
  3. This is similar to the first one except it will be applicable for the complete shell script. By adding
    #!/bin/sh -vx
    to the beginning of the shell script

Labels: , ,


About this entry