In linux, check whether the variable has been set. $ {test:-newvalue} is mainly used to test whether the variable test has been defined. If so
Print the defined value. If there is no value, the newvalue is printed,
Value is assigned to the test variable. Example of www.2cto.com: [root @ redhat ~] # Test = "blue" [root @ redhat ~] # Echo "the sky is $ {test:-gray} today"; the sky is blue today [root @ redhat ~] # Unset test [root @ redhat ~] # Echo "the sky is $ {test:-gray} today"; the sky is gray today www.2cto.com [root @ redhat ~] # Unset test [root @ redhat ~] # Echo "the sky is $ {test:-gray} today"; the sky is gray today [root @ redhat ~] # Echo $ {test} # Here Is www.2cto.com 2. $ {test: = newvalue} without the test variable. Let's take a look at $ {test: = newvalue} [root @ redhat ~]. # Echo "the sky is $ {test: = gray} today"; the sky is gray today [root @ redhat ~] # Echo $ {test} gray # obviously, $ {test: = newvalue} not only prints the value of newvalue when the test variable is not set,
In addition, newvalue is assigned to the test variable.