这个 stackoverflow 问题的答案 In a Linux shell how can I process each line of a multiline string?提到 $'\n'
是一种特殊语法“并非在每个 shell 中都可用”。
我想知道语法是什么意思?
谢谢。
最佳答案
请参阅 bash
手册页的 QUOTING
部分:
Words of the form $'string' are treated specially. The word expands to
string, with backslash-escaped characters replaced as specified by the
ANSI C standard. Backslash escape sequences, if present, are decoded as
follows:
...
\n new line
...
The expanded result is single-quoted, as if the dollar sign had not been
present.
此语法不是标准 Unix Bourne shell 的一部分。它可能是 bash 特有的,尽管我没有四处查看其他 shell 是否支持它。
关于linux - $'\n' 在 bash 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13925879/