Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
至少在 bash 模式替换中经常使用以下引号:$' '例如${arr[@]/%/$'\n\n\n'}在每个数组“arr”项之后打印三个换行符。这些是某种特殊的报价吗?他们怎么称呼?除了 bash 模式替换之外,它们还用在哪里?
$' '
${arr[@]/%/$'\n\n\n'}
ANSI-C 引用
形式的词$'string'被特殊对待。该单词扩展为字符串,并按照 ANSI C 标准的规定替换反斜杠转义字符。
$'string'
例如:
$'hello\nworld'
你会得到中间11有换行符的字符。
11
echo -e 'hello\nworld' echo $'hello\nworld'
他们给你同样的结果。