Special characters |
Purpose |
Description |
$ Variable |
Get the value of a variable. If it is not initialized, It is null. |
Returns the value of "variable". If it is not initialized, null is returned. |
$ {Variable} |
Get the value of a variable. If it is not initialized, It is null. It is usually used when other things are to be added to the variable value. |
Returns the value of "variable". If it is not initialized, null is returned. |
$ {Variable:-string} |
Obtain the value of a variable. If the variable is not defined, a definite value is returned. |
Returns the value of a variable when "variable" exists and is not a null value. Otherwise, "string" is returned" |
$ {Variable: = string} |
If a variable is not defined, a known value is assigned to it and this value is returned. |
Returns the value of the variable when "variable" exists and is not a null value. Otherwise, "string" is assigned to "variable" and "string" is returned" |
$ {Variable :? String} |
If the variable is not defined, a message is displayed. |
Returns the value of the variable when "variable" exists and is not null. Otherwise, the string "variable:" is displayed and "message" is displayed" |
$ {Variable: + string} |
Test whether a variable exists. |
If "variable" exists and is not null, "string" is returned; otherwise, "string" is returned" |
Bash reads and writes shell Variables