Powershell Escape character

Source: Internet
Author: User

Talk today about the escape character for PowerShell

What is an escape character, the escape character in the upper-left corner of the keyboard and ~ is a key that uses the escape character to turn some special characters into normal characters, or to use escape characters for some characters to become additional functional characters
For example:

PS C:\Windows\system32> $a=8PS C:\Windows\system32> $b="$a is 8"PS C:\Windows\system32> $b8 is 8

Normally, the $ symbol in double quotes is recognized as a variable, but if we add an escape character before the $ symbol, then $ is no longer recognized as a variable, but as a normal character, as follows:

PS C:\Windows\system32> $a=8PS C:\Windows\system32> $b="`$a is 8"PS C:\Windows\system32> $b$a is 8

In addition, the escape character is often used for code wrapping, and if a line of code is too long to exceed the display range of the screen, then we can break the line by escaping the character without affecting the continuity of the code.

Get-WmiObject -Class win32_bios `| select serialnumberserialnumber------------2VBCQF2

If we do not include an escape character after the BIOS, the code will error

PS C:\Windows\system32> Get-WmiObject -Class win32_bios | select serialnumber所在位置 行:2 字符: 1+ | select serialnumber+ ~不允许使用空管道元素。    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException    + FullyQualifiedErrorId : EmptyPipeElement

Another use of escape characters is to add an escape character to certain character signatures, which are converted to certain functions rather than the original character meaning, in the following ways
0 表示空<br/>A beep noise
b 回退一个字符<br/>F page breaks, printing characters, indicating that the next page of the current character continues to print
n 换行<br/>R Enter to delete the entire line before the character
t 水平Tab<br/>V Vertical tab, the cursor advances to the next vertical tab stop and starts writing to all subsequent outputs. This character affects only the printed document and does not affect the screen output

Powershell Escape character

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.