This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10605|Reply: 0

Meaning of the percentage sign (%) in PowerShell

[Copy link]
Posted on 12/22/2016 10:54:43 AM | | | |
Meaning of the percentage sign (%) in PowerShell

In PowerShell code, we often see code like this:
PS C:\Users\test> Get-Childitem c:\ | % {$_. Name}

$_ here represents the cyclic variable.

Next, let's look at this percent sign (%), which is followed by a pair of curly braces ({}) and a variable expression in the curly brace.
What this code does is get all the subobjects in the c:\ directory, including all the files and folders. These objects are then output to the next statement.
The percent sign (%) is a circular statement, which is an alias for ForEach-Object. “% {$_. Name}" statement is to loop out all the object names.





Previous:PowerShell displays the program associated with the file extension
Next:Percent sign "%" and question mark "?" in PowerShell.
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com