Shellscript tracking and debugging

Source: Internet
Author: User

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

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.