Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Powershell escape character

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Let's talk about the escape characters of Powershell today.

What is an escape character? the escape character is a key in the upper left corner of the keyboard. After using the escape character, some characters with special meaning become ordinary characters, or some characters become other functional characters after using escape characters.

For example:

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

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

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

In addition, escape characters are often used for code wrapping. If a line of code is too long to be displayed on the screen, we can wrap it by escaping characters without affecting the continuity of the code.

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

If we do not add escape characters after bios, then this code will report an error

PS C:\ Windows\ system32 > Get-WmiObject-Class win32_bios | Line where the select serialnumber is located: 2 characters: 1 + | select serialnumber+ ~ empty pipe elements are not allowed. + CategoryInfo: ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId: EmptyPipeElement

Another use of escape characters is to add escape characters to some character signatures, which are converted to certain functions rather than the original meaning of the characters, including the following

0 indicates that empty an emits a beep code

B rollback one character f page change, print the character, indicating to continue printing on the next page of the current character

N line feed r enter, the whole line before the character will be deleted

T horizontal Tabv vertical tab, the cursor advances to the next vertical tab stop and writes all subsequent outputs from there. This character only affects the printed document, not the screen output.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report