为什么linux PS1变量的内容用单引号而非双引号围起来?
PHPz
PHPz 2017-04-17 12:08:17
0
3
744

书上说单引号表示原字符,而双引号能表示出内在含义.那为何linux中PS1变量用单引号围起来却能表达出内在含义?
比如这样:

[root]#set |grep PS1
PS1='[\u]\$'
[root]#

百度也查到了同样的问题,但明显没回答好

PHPz
PHPz

学习是最好的投资!

reply all(3)
PHPzhong

The value of PS1 here is [u]$. The reason why it is finally displayed as [root]# is entirely because bash has done another explanation operation!
Because bash needs to explain how to display it after seeing [u]$. According to bash rules, u is to display the login account name. $You can search it yourself.

迷茫

Single quotes are not escaped, double quotes are escaped, for example, a='123', then
echo ‘a$a’
The output is a$a
echo “a$a”
The output is a123

洪涛

Has your file been resolved? I have the same problem and I couldn’t find the answer online

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template