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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.