Shell tracking options

Source: Internet
Author: User

If the command "Set-X" is added to the script file, each command executed after the set command and any parameters added to the command line (including the values of variables and variables) will be displayed. A plus sign (+) is added before each line, prompting that it is the identifier of the trace output. The shell trace Command executed in the sub-shell will add two plus signs ("++ ".

For example:

#! /Bin/sh

Set-x
Echo-n "can you write device drivers? "
Read answer
Answer = 'echo $ answer | tr [A-Z] [A-Z]'

If [$ answer = 'y']
Then
Echo "Wow, you must be very skilled"
Else
Echo "neither can I, I'm just an example shell script"
Fi

 

Use the xtrace (-x) option to check whether the code runs as expected. If you just want to see the code of the running script file, the shell redundancy option-V is very useful. The syntax for closing and opening options is the opposite. You can use the minus sign of-X to open an option, or use the plus sign, for example, + X to close an option.

 

Note: spaces are not allowed to assign values. For example, answer = 'echo $ answer | tr [A-Z] [A-Z]'

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.