You can use the x option of the set command to display all command execution and variable value change processes.
Usage: First UseSet-x to enable debugging, And finally use the commandSet + x disable debugging mode.
A simple example shows how to use the set command for script debugging:
! /Bin ///-
++ X
[Root @ localhost shell] #./+ NAME = ++ x
In the preceding results, you must note that all rows starting with the plus sign "+" are executed commands, and all rows without the plus sign "+" at the beginning are Script output, all variables in the script are replaced by values.
If there is a logic error in the script, you can clearly see the script execution process and error location during the above debugging process.
When you use the x option of the set command to start the debugging mode, you do not have to debug all statements, you can also use set-x and set + x to debug one or more problematic scripts.