How to use quotation marks in Shell

Source: Internet
Author: User

1. Shell uses quotation marks (single quotation marks/double quotation marks) and backslash ("\") for the shell interpreterSHIELD special characters.

Reverse quotation marks [H2] have special significance for shell.

1.1 single quotes and backlash [H1] can prevent shell from being substituted into variable values;

1.2 double quotation marks cannot prevent substitution

For example:

Sles10i32-1: Han $ person = Han

Sles10i32-1: Han $ echo $ person

Han

Sles10i32-1: Han $ echo "$ person"

Han

Sles10i32-1: Han $ echo '$ person'

$ Person

Sles10i32-1: Han $ echo \ $ person

$ Person

  1. Like single quotes, The backslash can also block all special characters. However, it can only block one character at a time, rather than a group of characters.
  2. The anti-quotation mark function is different from the above three symbols. It does not have the function of shielding special characters. However, you can pass the running result of a command to another command.

Example:

Sles10i32-1: Han $ PWD.

/Users/Han

Sles10i32-1: Han $ echo 'pwd'

/Users/Han

[H1] The backslash can only block one character

[H2] in the upper left corner of the keyboard, and ~ Public a key.

Related Article

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.