about_Escape_Characters
업데이트 날짜: 2014년 5월
적용 대상: Windows PowerShell 2.0, Windows PowerShell 3.0, Windows PowerShell 4.0
항목
about_Escape_Characters
간단한 설명
Windows PowerShell®의 이스케이프 문자를 소개하고 사용 결과에 대해 설명합니다.
자세한 설명
이스케이프 문자는 뒤에 오는 문자에 특수 해석을 할당하는 데 사용됩니다.
Windows PowerShell에서 이스케이프 문자는 억음 악센트 기호(ASCII 96)라고도 하는 억음 기호(`)입니다. 이스케이프 문자를 사용하여 리터럴, 줄 연속 및 특수 문자를 나타낼 수 있습니다.
다른 프로그램 호출에서 Windows PowerShell이 프로그램 인수를 잘못 해석하지 않도록 이스케이프 문자를 사용하는 대신 구문 분석 중지 기호(--%)를 사용할 수 있습니다. 구문 분석 중지 기호는 Windows PowerShell 3.0에 도입되었습니다.
변수 이스케이프
이스케이프 문자가 변수 앞에 추가되면 변수가 값으로 대체되지 않습니다.
예를 들면 다음과 같습니다.
PS C:\>$a = 5
PS C:\>"The value is stored in $a."
The value is stored in 5.
PS C:\>$a = 5
PS C:\>"The value is stored in `$a."
The value is stored in $a.
따옴표 이스케이프
이스케이프 문자가 큰따옴표 앞에 추가되면 Windows PowerShell에서는 큰따옴표를 문자열 구분 기호가 아닌 문자로 해석합니다.
PS C:\> "Use quotation marks (") to indicate a string."
Unexpected token ')' in expression or statement.
At line:1 char:25
+ "Use quotation marks (") <<<< to indicate a string."
PS C:\> "Use quotation marks (`") to indicate a string."
Use quotation marks (") to indicate a string.
줄 연속 사용
이스케이프 문자는 명령이 다음 줄에서 계속되도록 Windows PowerShell에 지시합니다.
예를 들면 다음과 같습니다.
PS 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 Alert
`b Backspace
`f Form feed
`n New line
`r Carriage return
`t Horizontal tab
`v Vertical tab
예를 들면 다음과 같습니다.
PS C:\> "12345678123456781`nCol1`tColumn2`tCol3"
12345678123456781
Col1 Column2 Col3
자세한 내용을 보려면 다음을 입력합니다.
Get-Help about_Special_Characters
구문 분석 중지 기호
다른 프로그램을 호출할 때 구문 분석 중지 기호(--%)를 사용하여 Windows PowerShell이 오류를 생성하거나 프로그램 인수를 잘못 해석하지 않도록 할 수 있습니다. 프로그램 호출에서 이스케이프 문자 대신 구문 분석 중지 기호를 사용할 수 있습니다. 이 기호는 Windows PowerShell3.0에 도입되었습니다.
예를 들어 다음 명령은 Icacls 명령에서 구문 분석 중지 기호를 사용합니다.
icacls X:\VMS --% /grant Dom\HVAdmin:(CI)(OI)F
구문 분석 중지 기호에 대한 자세한 내용은 about_Parsing을 참조하세요.
참고 항목
about_Quoting_Rules