From the course: Linux System Engineer: Bash Shell Scripting for Automation

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using bash debugging mode

Using bash debugging mode

From the course: Linux System Engineer: Bash Shell Scripting for Automation

Start my 1-month free trial

Using bash debugging mode

- [Instructor] Bash doesn't have the complex debugging facilities that other languages have. But knowing right up front that we can watch what Bash is doing, helps. We have two methods of using Bash's debugging mode. We can provide the -x option to Bash when we call a script, which looks like this. Or, we can put set, Space, -X inside of our script. The difference is, that running a script with bash -x turns the debugger on for the entire script. Whereas, using set -x inside of our script allows us to debug just portions, by turning the debugger on, and then back off again. The reason we might want to do this, is that the debugger outputs a lot of text on the screen, and having to dig through debugging information for the entire script is a lot of work. Real error information may get lost in the output. Let's use the bash debugger now. Because our first two scripts are so simple, the debugger won't output much. Let's quickly create a new script. Type in, cd ~/bin, and hit Enter. Now…

Contents