Scripts are afraid of problems before they are executed. Linux provides no need to judge if there is a problem by directly executing the script.
[Email protected]]# SH-NVX scripts.sh
Parameters:
-N Do not execute script, only check for syntax issues
-V Output the contents of the script to the screen before the script executes
-X Displays the contents of the script used to the screen, which is the most useful parameter.
For example, there is a script file test.sh, afraid of problems before running the script, you can use the path provided by Linux to check if the script is faulty.
Example one: Test Sh16. Does sh have any grammatical problems?
< Span style= "color: #0000ff; Line-height:1.5!important; " > [[email protected] ~]# sh-n sh16. sh
# If there is no problem with the syntax, no information will be displayed!
[Email protected]]# sh-x test.sh
The-x parameter can be executed at the top of all the program segments to execute. If it is a program segment, the output is preceded by a "+" symbol, which indicates that it is a program segment.
Attention!!!
Linux has a large number of script files, if not until the function of the script, you can use the VIM editor to open the script file, through the system of its description (description) can be understood.
Shell script Tracking and debug