- PowerShell 教程
- PowerShell - 主頁
- PowerShell - 概覽
- PowerShell - 環境設定
- PowerShell - Cmdlet
- PowerShell - 檔案與資料夾
- PowerShell - 日期與計時器
- PowerShell - 檔案輸入/輸出
- PowerShell - 高階 Cmdlet
- PowerShell - 指令碼
- PowerShell - 特殊變數
- PowerShell - 運算子
- PowerShell - 迴圈
- PowerShell - 條件
- PowerShell - 陣列
- PowerShell - 雜湊表
- PowerShell - 正則表示式
- PowerShell - 反引號
- PowerShell - 括號
- PowerShell - 別名
- PowerShell 有用資源
- PowerShell - 快速指南
- PowerShell - 有用資源
- PowerShell - 討論
Powershell - Measure-Object Cmdlet
Cmdlet
Measure-Object cmdlet 可用於獲取已傳遞輸出的屬性,例如最小值、最大值、大小、數量、行等。
在這些示例中,我們將看到 Measure-Object cmdlet 如何執行。
示例 1
在此示例中,我們首先在 D:\temp\test 中有一個名為 test.txt 的檔案,其內容為“Welcome to TutorialsPoint.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 :
powershell_advanced_cmdlets.htm
廣告