Environment variables, positional parameter variables, predefined variables

Source: Internet
Author: User

Environment variables

Set environment variable: 1. Export variable name = variable Value

2. Variable name = variable Value

Export variable Name

(export variable name = variable Value: Declare the variable as an environment variable so that all child shells in the shell can see the variable being used)

Query variable: env

View process tree: Pstree

Path: Paths to System lookup commands

Path= "$PATH":/root/sh→path variable Overlay (temporary)

System default environment variable names are uppercase

Positional parameter variables

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

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

[Email protected]: This variable also represents all parameters in the command line, but [email protected] treats each parameter differently

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

Pre-defined variables

$?: The return status of the last command executed. If the value of this variable is 0, it proves that the previous command was executed correctly, and if the value of this variable is not 0 (which is the tree, which is determined by the command itself), then the last command was executed incorrectly.

$$: Process number of the current process

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

command to join &, command backstage

Accept keyboard input →read option variable name

-P "prompt message": Output prompt when waiting for read input

-T seconds: the read command waits for user input, using this option to specify the wait time

-N Character number: The Read command accepts only the specified number of characters and executes

-S: Hide input data, apply to confidential information input

Environment variables, positional parameter variables, predefined variables

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.