In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the "git user-defined variable view modification and call method", in the daily operation, I believe that many people have doubts in the git user-defined variable view modification and call method problem, the editor consulted all kinds of data, sorted out a simple and easy-to-use operation method, hope to answer the "git user-defined variable view modification and call method" doubt to help! Next, please follow the editor to study!
1. Variable definition
Variables are defined correctly.
Format: variable name = "variable value"
# both can be [root@localhost ~] # name=zhenniubi [root@localhost ~] # name= "zhenniubi"
Variable names cannot start with a number.
[root@localhost ~] # 2name = "zhen niubi"-bash:2name=zhen niubi:command not found
There can be no spaces on the left and right sides of the equal sign.
[root@localhost ~] # name = "zhenniubi"-bash:name:command not found
If the value of a variable has spaces, it must be enclosed in quotation marks.
[root@localhost ~] # name=zhen niubi-bash:niubi:command not found2, variable call
Call variables with the $symbol.
# define variable name [root@localhost ~] # name= "zhen niubi" # output variable name value [root@localhost ~] # echo $namezhen niubi3, variable modification
The modification of the value of a variable in Shell is done in the form of an override, and the last assignment of the variable will prevail.
# previously defined variable [root@localhost ~] # name=ailin [root@localhost ~] # [root@localhost ~] # echo $nameailin# modified variable value [root@localhost ~] # name=cangls [root@localhost ~] # [root@localhost ~] # echo $namecangls4, check the variable
Command format:
[root@localhost ~] # set [options]
Options:
-u: if this option is set, an error will be reported when calling an undeclared variable (without any prompt by default) (very common).
-x: if this option is set, the command will be output once before the command is executed. (not recommended)
(1) the-u option states:
The age field (variable) has never been defined under the current system, and the value of the age variable is output directly. As shown in the figure below, you can see that there is no value.
If I define a null value for the age field, I can see that there is still no output in the age field, as shown in the figure below.
So to sum up, there are two possibilities for viewing a variable without any output. One is that the age variable does not exist, and the other is that the value of the age variable is empty. In Java, variables that are not defined and variables whose values are empty are two completely different concepts, as well as in Shell, which we must distinguish.
If I execute the set-u command, I can distinguish between the above two cases.
# execute the command `set-u` directly [root@localhost ~] # set-u# to output an undefined variable, which shows that the addr variable does not exist. [root@localhost ~] # echo $addr-bash: addr: unbound variable# defines a null value for the addr variable. # when you look at the variable, you can see that the value of the variable is empty. [root@localhost ~] # addr= "" [root@localhost ~] # echo $addr [root@localhost ~] #
Note: execute the set-u command on the command line, which is temporary and needs to be permanent, so it needs to be written to the environment variable configuration file. (how to configure it, see the future configuration of environment variables.)
Summary: when the-u option is set, an error will be reported if you call a variable that is not set. There is no output by default.
(2)-x option description:
Literally, if the-x option is set, the command will be output once before each command is executed
[root@localhost ~] # set-x [root@localhost ~] # ls+ ls-color=auto anaconda-ks.cfg install.log install.log.syslog sh tdir test testfile
If you do not log in to the system, this will always be the case, because as mentioned above, direct execution on the command line is temporary. This option is not recommended, and the command results look messy.
(3) set command description:
Using the set command directly, without any options, will query all variables in the system, including user-defined variables and environment variables. (actually, it's part of it)
Another part of the system variable is viewed with the env command. The variables seen by the two commands overlap, but the env command cannot see the custom variables. (checked, the introduction on the Internet is also very vague, that is, two commands can find all the variables in the system, set is mostly used to view the user-defined variables of the system, and env is mostly used to query the environment variables of the system. )
Summary:
Set: the variable used to display the current Shell, including the variable for the current user.
Each Shell has its own unique variable, which is different from the user variable, the current user variable has nothing to do with what Shell you use, no matter what Shell you use, each Shell has a custom Shell, that is, its own Shell variable. This kind of variable is different from Shell, these variables are only displayed by set, and are unique to bash. This variable is also valid only for this Shell and cannot be passed to the child Shell. (equivalent to a local variable in Java).
Env: used to display environment variables, also known as variables that show the current user, environment variables can be passed to the child Shell. (equivalent to global variables in Java)
5. Delete [root@localhost ~] # unset variable name
There is no need to prefix the $symbol to the variable name, only when the variable value is called.
At this point, the study on "git user-defined variables to view the modification and call methods" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.