Escape character
#!/bin/Basha=tenecho"Value of A is $a \ n"
Replace the escape character with the-e representation, which is not escaped by default
Command substitution
The syntax for command substitution, note is the inverse quotation mark, not the single quotation mark, this key is below the ESC key.
' Command '
You can save the results of a command execution in a variable and use it when needed
#!/bin/bashdate=' Date 'echo' Now '${date}'
Variable substitution
Variable substitution can change its value depending on the state of the variable (whether it is empty, whether it is defined, etc.)
Variable substitution forms that you can use:
Here is an example of variable substitution
#!/bin/BashEcho${var:-"Variable is not set"}Echo "1-value of Var is ${var}"Echo${var:="Variable is not set"}Echo "2-value of Var is ${var}"unset varEcho${var:+"The is default value"}Echo "3-value of Var is $var"var="Prefix"Echo${var:+"The is default value"}Echo "4-value of Var is $var"Echo${var:?"Print This message"}Echo "5-value of Var is ${var}"
Run results
Shell script: Replace