bash - bash 中的三单引号是什么意思?
问题描述
我在 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.
解决方案
没有“三引号”......例如''' '$Q' '''
是几个字符串的连接...... ''
,,,' '
和。以同样的方式考虑其他每一个。$Q
' '
''
推荐阅读
- python - 将数据集拆分为训练和测试以在 python 中进行时间序列分析
- javascript - 为什么我的 useEffect 中仍然有陈旧的数据?
- javascript - Angular - 惊人的时间选择器(ATP)TimePicker在选择小时后不会切换到分钟
- youtube-data-api - YouTube V3 LiveBroadcasts:列出服务帐户凭据问题
- arrays - 如何从具有多个对象的嵌套数组中提取信息?(AdminReport.Activity.list)
- amazon-web-services - AWS API 网关配置来自不同区域的 vpc 端点 ID
- javascript - Javascript 正则表达式 - 金额中的第一个数字接受非零
- c++ - 使用一个 cout 命令打印多个字符串,每个字符串放在不同的(文本编辑器)行
- ubuntu-16.04 - 执行 catkin_make 时出错:调用“make -j1 -l1”失败
- python - 找不到确定安装的模块