Linux 单、双引号与转义符号
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash

·
Q1 单引号内符号不会被转义
在Linux内单引号内是不能引用变量的,使用''''
可以使单引号可以使用引用变量。
[root@ scripts]# q1=abc
[root@ scripts]# echo $q1
abc
[root@ scripts]# echo '$q1'
$q1
#[root@ scripts]# echo ''$q1''
abc
Q2 使用=
赋值会导致转义符(冒号等)丢失
在Linux内使用=
对于字符串进行操作的时候,会导致转义符号的丢失。所以,需要在赋值之前,进行手动转义,或者使用符号进行转义。
[root@ scripts]# q2="abc"
[root@ scripts]# echo $q2
abc
[root@ scripts]# q2=\"abc\"
[root@ scripts]# echo $q2
"abc"
Reference
[1]. shell单引号与变量




A beautiful web dashboard for Linux
最近提交(Master分支:19 天前 )
186a802e
added ecosystem file for PM2 5 年前
5def40a3
Add host customization support for the NodeJS version 5 年前
更多推荐
所有评论(0)