Variable configuration rules
- The variable and the variable content are linked with an equal sign "=", as shown below:
"Myname = vbird 』
- The equal sign cannot be directly followed by a space character, as shown below:
"Myname = vbird" or "myname = vbird Tsai 』
- The variable name can only contain English letters and numbers, but cannot start with a number. The following is an error:
"2 myname = vbird 』
- If there is a space character in the variable content, you can use double quotation marks "or single quotation marks" '"to combine the variable content,
- Special characters in double quotation marks, such as $, can retain the original features, as shown below:
For "Var =" Lang is $ Lang "", "Echo $ Var" can obtain "Lang is en_us 』
- Special characters in single quotes are only common characters (plain text), as shown below:
For "Var = 'lang is $ Lang '", "Echo $ Var" can obtain "Lang is $ Lang 』
- The Escape Character "\" can be used to place special characters (such as [enter], $, \, space characters,
', Etc.) to a general character;
- You can use the 'command' or
'$ (Command )』. Note that the one on the left of the number key 1 on the top of the keyboard is not a single quotation mark!
For example, to obtain the configuration of the core version:
"Version = $ (uname-R)" and then "Echo
For $ version, see "2.6.18-128. EL5 』
- If the variable is an expanded variable, you can use "$ variable name" or "$ {Variable}" to accumulate the content, as shown below:
"Path =" $ path ":/home/bin 』
- If the variable needs to be run in another subroutine, you need to use export to convert the variable into an environment variable:
"Export path 』
- Generally, upper-case characters are default variables of the system. You can use lower-case characters to configure variables for easy judgment (purely based on user interests and hobbies );
- To cancel a variable, use unset: "Unset
For example, cancel the configuration of myname:
"Unset myname 』
[Transfer] http://vbird.dic.ksu.edu.tw/linux_basic/0320bash_2.php