这个stackoverflow问题的答案在Linux shell中,我如何处理多行字符串的每一行?提到这$'\n'是一种特殊的语法"在每个shell中都不可用".
我想知道语法是什么意思?
谢谢.
请参见手册页的QUOTING部分bash:
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.
Run Code Online (Sandbox Code Playgroud)
此语法不是标准Unix Bourne shell的一部分.它可能是特定于bash,虽然我没有环顾四周看其他shell是否支持它.