The essential point in programming is debugging, Shell script with its powerful function is desirable, of course, its powerful is not only embodied in the language of the implementation function, more powerful is its debugging function, below, I will illustrate the shell script debugging technology.
Here are the examples I used:
#!/bin/bash
line= "Tests run:196, failures:1, errors:1"
error= ' echo $LINE |cut-d ': '-f4 '
echo $ Error
error=0
error=$ (($error + $ERROR))
Echo $ERROR
There are two ways to run this example:
1. Add execution permissions to the file chmod a+x sleep.sh
2. Perform SH sleep.sh as command line parameters
The results of the operation are shown in the following illustration:
As we can see, this shows only the execution results, so what if I wanted to know how the script was executed?
There are also two ways to use:
1. Add the corresponding parameters at run time
Bash-x sleep.sh
2. Add the appropriate information at the beginning of the script file
#!/bin/bash-xv
line= "Tests run:196, failures:1, errors:1" error= '
echo $LINE |cut-d ': '-f4 '
Echo $error
Error=0
error=$ (($error + $ERROR))
Echo $ERROR
We can see that the first line joins the-XV
Let's run this script one more time, and the results are as follows:
Here I'm done with the shell script debugging.