Powershell-Measure-Object Cmdlet

时间:2019-08-20 13:51:05  来源:igfitidea点击:

Cmdlet

Measure Object cmdlet可用于获取传递的输出的属性,如min、max、size、count、line等。

例1

在这个例子中,在D:\temp\test中,我们有一个文件test.txt,内容为“欢迎使用theitroad.com网站".

在PowerShell ISE控制台中键入以下命令

get-content D:\temp\test\test.txt | measure-object -character -line -word

输出

我们可以在PowerShell控制台中看到以下输出。

Lines                   Words              Characters Property               
   -----                   -----              ---------- --------               
     1                       3                      29

例2

计算当前目录中存在的文件数。

在PowerShell ISE控制台中键入以下命令

Get-ChildItem | Measure-Object

输出

我们可以在PowerShell控制台中看到以下输出。

Count    : 25
 Average  : 
 Sum      : 
 Maximum  : 
 Minimum  : 
 Property :