书上说单引号表示原字符,而双引号能表示出内在含义.那为何linux中PS1变量用单引号围起来却能表达出内在含义?
比如这样:
[root]#set |grep PS1
PS1='[\u]\$'
[root]#
百度也查到了同样的问题,但明显没回答好
PHPz2017-04-17 12:10:17
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.
迷茫2017-04-17 12:10:17
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
PHP中文网2017-04-17 12:10:17
Has your file been resolved? I have the same problem and I couldn’t find the answer online