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