Monday, March 11, 2013

Starting Up the Bash Subshell with the -x Option

You can enable debugging mode within a bash script, say, by adding the following command line:
  • set -x

For example,

set -x

Adding "set -x" in the script, it enables the printing of command traces before executing command.  This is equivalent to the long command notation:

  • set -o xtrace

However, there are cases that you cannot modify the bash script itself because of permission or you simply don't want to modify the file.  Then there is another option:

$ bash -x

This will allow you to execute the script with command traces which are good for debugging.


  1. Bash Guide for Beginners

No comments: