Shell quotes are useful

Source: Internet
Author: User

1 single quotation marks


Single quotation marks can be used to restore the literal meaning of characters, to implement the function of shielding metacharacters, single quotes must be used in pairs

[Email protected]~]# echo ' $JAVA _home '

Special features $JAVA _home #实现屏蔽 $

[[Email protected]~]# echo ' CD \home '

CD \home #实现屏蔽转义字符 \


2 double Quotes


Double quotation marks are basically the same as single quotes, but they do not mask the function of the $ ' \ Three metacharacters, and if you want to block them, you must precede them with a \,

[Email protected]~]# echo "$JAVA _home" #双引号直接输出了变量

/usr/java/jdk1.7.1_8

[Email protected]~]# echo "It s your book"

It ' s your book

[[Email protected]~]# echo ' \ $JAVA _home ' #用 \ Escape, output the following characters directly

$JAVA _home


3 anti-Quote

Reverse quotation marks are command substitution, replacing command characters with command result output


[Email protected]~]# echo "Today is ' Date '" #直接输出date命令的结果

Today is Fri Dec 11:50:20 CTS 2016



This article is from the "Practical Linux knowledge and Skills sharing" blog, please be sure to keep this source http://superleedo.blog.51cto.com/12164670/1887616

Shell quotes are useful

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.