Shellscript tracking and debugging
1. shell script debugging
Run the sh command to check the shell syntax and follow up the execution steps. Sh [-nvx] script. sh-n: do not execute the script. Only check for Syntax problems.-v: print the script out before execution.-x: print the used script out.
2. Check for syntax errors
Use sh-n. If a syntax error occurs, a prompt is displayed.
[Work @ www sh] $ sh-n. sh. sh: line 7: syntax error near unexpected token 'O'. sh: line 7: 'O' [work @ www sh] $
3. shell debugging and Printing
[Work @ www sh] $ sh-v for. sh #! /Bin/bash # desc: for loopfor animal in dog cat pig do echo "HI, $ {animal}" doneHI, dogHI, catHI, pigexit; [work @ www sh] $
[Work @ www sh] $ sh-x. sh + for animal in dog cat pig + echo 'Hi, dog' HI, dog + for animal in dog cat pig + echo 'Hi, cat' HI, cat + for animal in dog cat pig + echo 'Hi, pig' HI, pig + exit [work @ www sh] $
Address: http://blog.csdn.net/yonggang7/article/details/40680369