shell bash中的三重单引号是什么意思?

0wi1tuuw  于 12个月前  发布在  Shell
关注(0)|答案(1)|浏览(158)

我在bash中看到过很多单引号和双引号的用法,以及反引号,但从未见过下面的用法。下面的文字记录是什么意思,它似乎表明三重单引号被bash认为是有意义的,并且进一步似乎表明这个东西里面的单引号也有特殊的意义,可以进行插值?我没有发现任何这方面的文件。

$ Q=test
$ echo '$Q'                      # <== I know, this doesn't work...
$Q                               # <== ...and so it doesn't. 
$ echo '''$Q'''                  # <== Don't know what this could mean.
$Q                               # <== OK, nothing special?
$ echo ''' "$Q" '''              # <== Try a double-quote??
 "$Q"                            # <== Hmm... OK, nothing.
$ echo ''' '$Q' '''              # <== Try a single-quote?
 test                            # <== Wow, it did interpolate!?
$ echo '''                         
> '''                            # <== Continuation! Proving bash  
                                 #     thinks this is an opening 
                                 #     quote of some kind.
$ bash --version                 # <== FYI,  version info
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.
jrcvhitl

jrcvhitl1#

没有“三重引用”...例如''' '$Q' '''是几个字符串的连接. ''' '$Q' '''。以同样的方式考虑其他人。

相关问题