Files
tldr/pages.zh/windows/measure-object.md

13 lines
681 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Measure-Object
> 计算对象的数值属性,以及字符串对象中的字符、单词和行,例如文本文件。
> 注意:此命令只能通过 PowerShell 使用。
> 更多信息:<https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/measure-object>。
- 计算目录中的文件和文件夹数量:
`Get-ChildItem | Measure-Object`
- 将输入通过管道传递给 Measure-Command通过管道传递给 `Measure-Command` 的对象可以在传递给 Expression 参数的脚本块中使用):
`"One", "Two", "Three", "Four" | Set-Content -Path "{{path\to\file}}"; Get-Content "{{path\to\file}}"; | Measure-Object -Character -Line -Word`