簡體   English   中英

bash中的$'\\ n'是什么意思?

[英]What does $'\n' mean in bash?

這個stackoverflow問題的答案在Linux shell中,如何處理多行字符串的每一行? 提到$'\\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支持它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM