Shell script tracing and debug

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.