30TROUBLESHOOTING

image

Now that our scripts become more complex, it’s time to look at what happens when things go wrong. In this chapter, we’ll look at some of the common kinds of errors that occur in scripts and examine a few useful techniques that can be used to track down and eradicate problems.

Syntactic Errors

One general class of errors is syntactic. Syntactic errors involve mistyping some element of shell syntax. The shell will stop executing a script when it encounters this type of error.

In the following discussions, we will use this script to demonstrate common types of errors.

#!/bin/bash# trouble: script to demonstrate common errorsnumber=1 ...

Get The Linux Command Line, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.