主題 about_Escape_Characters 簡短描述 介紹 Windows PowerShell 中的逸出字元並說明其效果。 完整描述 逸出字元會用來為其後的字元指派特殊的解譯。 在 Windows PowerShell 中,逸出字元是倒引號符號 (`),也稱為抑音符號 (ASCII 96)。逸出字元可用來表示常值、行接續以及特殊的字元。 表示常值 當逸出符號放在變數之前時,可防止值取代變數。當逸出字元放在雙引號之前時, PowerShell 會將雙引號解譯為字元,而非字串分隔字元。 例如: C:\>$a = 5 C:\>"The value is stored in $a." 值會儲存在 5 中。 C:\>$a = 5 C:\>"The value is stored in `$a." 值會儲存在 $a 中。 C:\> "Use quotation marks (") to indicate a string." 運算式或陳述式中有未預期的 ')' 語彙基元。 位於第 1 行,第 25 個字元 + "Use quotation marks (") <<<< to indicate a string." C:\> "Use quotation marks (`") to indicate a string." 使用引號 (") 表示字串。 表示行接續 逸出字元告訴 Windows PowerShell 命令會延續到下一行。 例如: C:\> get-process ` >> powershell Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 340 8 34556 31864 149 0.98 2036 powershell 表示特殊字元 用於引號內部時,逸出字元表示為命令剖析器提供指示的特殊字元。 Windows PowerShell 能夠辨識下列特殊字元: `0 Null `a 警示 `b 退格鍵 `f 換頁字元 `n 新行字元 `r 換行字元 `t 水平定位字元 `v 垂直定位字元 例如: C:\> "12345678123456781`nCol1`tColumn2`tCol3" 12345678123456781 Col1 Column2 Col3 如需詳細資訊,請輸入: get-help about_special_characters 請參閱 about_Quoting_Rules