Linux Shell Basics-Bash variables-environment variables-positional parameter variables-predefined variables

Source: Internet
Author: User

01. Environment variable = + user-defined variables take effect only in the current shell, and environment variables take effect in the current shell and all child shells of the shell.

If you write the environment variable to the appropriate configuration file, the environment variable will take effect in all the shells,

02. Setting Environment Variables = = Export variable name = variable Value

Declaration variables

View variables = env

View variable contents = Echo $ variable name

Delete variable = = unset variable name

03, the system common environment variables

(01) path to the System Lookup command

(02), PSI defines the system prompt variable

        

For example: [[email protected] ~]# psi= "[\[email protected]\t \w]\$": \u: Represents the root;\t on behalf of the hostname; \w (w lowercase, uppercase means absolute path) represents ~

04. Position parameter variable = write to script file

    

Example: Create a script canshu.sh: write echo $ echo echo $ echo $

Echo $0:$0 represents the command itself, and $1-$9 represents the first to the Nineth parameter.

When executing the script file:./canshu.sh 11 22 33

05. Pre-defined variables

$$: Output when the forward PID

This PID is the PID of the generated process when variable,sh this script executes;

06. Receive keyboard input = + red [option] [variable name]

-P "prompt message": When waiting for the read in and out, the output prompt read command will wait for user input, use this option to specify the time to wait

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

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

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

For example:

Linux Shell Basics-Bash variables-environment variables-positional parameter variables-predefined variables

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.