首页 > 系统服务 > 详细

Linux 单引号和双引号的区别

时间:2019-04-02 11:41:27      阅读:195      评论:0      收藏:0      [点我收藏+]

1.单引号

单引号将其中的内容都作为了字符串来,忽略所有的命令和特殊字符,类似于一个字符串的用法

$echo This is a string
This is a string
$echo ls ./
ls ./

2.双引号

双引号与单引号的区别在于其可以包含特殊字符,包括‘, ", $, \,如果要忽略特殊字符,就可以利用\来转义,忽略特殊字符,作为普通字符输出:

var = 1
echo $var
>>>$var
echo "$var"
>>> 1

echo "Here ‘this is a string‘ is a string"
>>> Here this is a string is a string

echo "Here \"this is a string\" is a string"
>>> Here "this is a string" is a string

3.反引号

反引号用来包含一个命令字符串的,其中的命令会先执行,得到的结果会返回到层命令再执行:

 

Linux 单引号和双引号的区别

原文:https://www.cnblogs.com/sayiqiu/p/10641483.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!