Parameters:
-N does not execute script, only checks syntax for errors
-V Output the script contents to the screen and execute the script
-X executes the script and outputs the content to the screen
-N
-V
Ten module () { eval '/usr/bin/modulecmd bash $*'}#/bin/bashif [$15 ];then "Yes"or "else" No " Fiyes
-X
[[Email protected] sbin]# SH-'['5']' 2operator expected+ echo Nono
Expand:
Use PS4 to make debugging output line numbers
[[email protected] sbin]# echo $PS 4+[[email protected] sbin]# export PS4='+{$LINENO} '[[email protected] sbin]# Sh-x debug.sh 4
+{2} ' [' 4-gt 5 '] '
+{5}echo No
No
Use set to narrow the scope of debugging
Set-x Turn on debug function
Set +x turn off the debug function
[email protected] sbin]# Cat demo.sh #/bin/bash./etc/init.d/functionsSet-Xread-P"pleas input your anwser[yes/no]:" anSet+xif[[$an =Yes]] Then action"The answer is true"/bin/trueElseAction"Then answer is False"/bin/falsefi[[email protected] sbin]# sh demo.sh+{4}read-p'pleas input your anwser[yes/no]:'Anpleas Input your anwser[yes/No]: Yes+{5}Set+XThe Answer is true[OK]
Shell Scripting Learning Summary 11--script debugging