Environment variable; location parameter variable; predefined variable, environment variable

Source: Internet
Author: User

Environment variable; location parameter variable; predefined variable, environment variable

Environment Variable

 

Set the environment variable: 1. export variable name = variable value

2. variable name = variable value

Export variable name

(Export variable name = variable value: declare this variable as an environment variable so that all the sub-shells in this SHELL can view and use this variable)

 

Query variable: env

 

View process tree: pstree

 

PATH: path of the system query command

PATH = "$ PATH":/root/sh → PATH variable superposition (temporary)

 

By default, all environment variable names are in uppercase.

 

Location Parameter Variable

 

$ N: n is a number, $0 represents the command itself, $1-$9 represents the first to 9th parameters, and more than 10 parameters are included in braces, such as $ {10}

$ *: This variable represents all parameters in the command line. $ * considers all parameters as a whole.

$ @: This variable also represents all parameters in the command line, but $ @ treats each parameter differently.

$ #: This variable represents the number of all parameters in the command line.

 

Predefined Variables

 

$? : The Return status of the Last Command executed. If the value of this variable is 0, it indicates that the previous command is correctly executed. If the value of this variable is not 0 (the specific tree is determined by the command ), the execution of the previous command is incorrect.

$: Process ID of the current process

$! : Process Number of the last process running in the background

Add the command & and run the command in the background.

 

Accept keyboard input → read option variable name

-P "prompt information": the prompt information is output while waiting for read input.

-T seconds: The read command will remain waiting for user input. You can use this option to specify the waiting time.

-N characters: The read command only accepts the specified number of characters and runs

-S: hides input data, which is applicable to input of confidential information.

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.