bash中的三重单引号是什么意思? [英] What does triple-single-quote mean in bash?

查看:79
本文介绍了bash中的三重单引号是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过bash中很多使用单引号和双引号以及反引号的用法,但从未见过.以下记录的含义是什么,它似乎表明bash认为三重单引号是有意义的,并且进一步表明该内容中的单引号也具有特殊含义,可以进行插值?我没有找到任何文档.

I have seen lots of uses of single and double-quotes in bash, as well as backtick-quotes, but have never seen what follows. What is the meaning of the transcript below, which seems to show that triple-single-quoting is recognized as meaningful by bash and further seems to show that single quotes inside this thing also have special meaning, enabling interpolation? I have found no documentation of this.

$ 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.

推荐答案

没有三引号" ...例如,''''$ Q''''是几个字符串... '''' $ Q ''''.以相同的方式考虑其他每个人.

There is no "triple quote" ... for example ''' '$Q' ''' is the concatenation of several strings ... '', ' ', $Q, ' ' and ''. Consider each of the others in the same way.

这篇关于bash中的三重单引号是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆