SED variable substitution and Linux special symbols encyclopedia

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.