Before scripts runs, the most feared problem is the syntax error! So how can we debug it? Is there a way to determine whether there is a problem without directly running the scripts? Haha! Of course! Let's take the bash-related parameters for determination!
[Root @ WWW ~] # Sh [-Nvx] scripts. Sh Options and parameters: - N: Do not run scripts. Only query syntax issues; - V: before running scammers, output the scripts content to the screen; - X: displays the used script content on the screen. This is a useful parameter! Example 1: Test sh16. Sh Are there any Syntax problems? [Root @ WWW ~] # Sh -N sh16. Sh # If the syntax is correct, no information is displayed! Example 2: Set sh15. Sh The running process is all listed ~ [Root @ WWW ~] # Sh -X sh15. Sh + Path =/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/ Bin + Export path + For Animal In Dog Cat Elephant + Echo ' There are dogs .... ' There are dogs .... + For Animal In Dog Cat Elephant + Echo ' There are cats .... ' There are cats .... + For Animal In DogCat Elephant + Echo ' There are elephants .... ' There are elephants ....
From http://vbird.dic.ksu.edu.tw/linux_basic/0340bashshell-scripts_6.php