1 SED supports the substitution of variables in two ways, it is recommended to use the following second, relatively simple
This allows the variable A to be assigned a number of special characters, such as Assignment a= '! @#¥% ... '
Sed-n ' s/echo/' "$a" '/P ' AA
Sed-n "s/echo/$a/P" AA
2 Linux special characters Daquan, see links
Shell Escape character |
Character |
Description |
‘’ |
Single quotes, hard escapes, and all shell metacharacters and wildcards inside them are turned off. Note that ' (single quotation marks) are not allowed in hard escaping. The enclosed quotation marks are treated as a single string. The $ sign that represents the variable within the quotation marks does not work, that is, he is treated as a general symbol and prevents any variable substitution. |
“” |
Double quotes, soft escapes, which are only allowed to appear within the specific shell metacharacters ($, ', \): $ for Variable value substitution, ' for command substitution, \ \ For escaping a single character |
\ |
Backslash, escaping, removes the special meaning of the meta-character or wildcard immediately followed. The content enclosed in double quotes is treated as a single string. It prevents wildcard expansion, but allows variable expansion. This is different from the single-argument approach |
Reference
Use variable substitution in sed and execute external command
Linux Special Symbols Encyclopedia
SED variable substitution and Linux special symbols encyclopedia