Bash Learning Note--shell variables

Source: Internet
Author: User
Tags echo command

Variables can be set in the shell environment for easy user use. The user can customize the variables, which can be implemented directly in the shell environment through simple syntax, for example: "x=100" and so on. At the same time, there are variables that can affect the operations of the Bash environment, called environment variables, such as Paht,home,mail, which are generally capitalized in order to differentiate themselves from custom variables. Where the path variable is the route for the shell to search for an external command (that is, an external app), and if no command is found in the path path, the shell displays the command cannot be found.

Variable contents can be displayed by the echo command, which requires a $ sign before the variable name. With respect to single quotes and double quotes, single quotes are strong references, and special symbols within single quotes do not maintain special meanings, only as a simple symbol. Double quotation marks are weak references, and the special symbols in them still retain their special meanings. For example, the $ sign within a single quotation mark is just a special symbol for the value of a variable as the $ symbol within the double quotation mark itself. Using export, you can change a variable to an environment variable so that it can be used by more than one process, such as a child process. Use the unset command to cancel a variable. With the env command, you can view all environment variables, and the SET command can view environment variables and custom variables.

Variables can be entered through the keyboard, do not necessarily have to set the variable content on the command line, so it is easier to interact with the user in the Bash shell script, using the Read command, the command form of read–pt variable, where p can be followed by a prompt, The number of seconds after which the T can wait.

A variable in the shell is generally a variable of type string, but it can also have other types of variables, such as Integer and array types, Declare–iarx variable, where I is the integer type, a is an array type, R is a read-only type, and x is an environment variable.

Bash Learning Note--shell 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.