Commands / Text and objects

Measure-Object

Count, sum, or average

beginner Text and objects Aliases measure

Measure-Object
 Get-ChildItem -File | Measure-Object -Property Length -Sum
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Measure-Object

Without parameters it counts. With -Property Length -Sum it adds file sizes. Also supports -Average, -Minimum, -Maximum, and -Line / -Word / -Character for text.

Try this

Get-Content -Path .\notes.txt | Measure-Object -Line -Word

Coming from another shell

ShellWhat you might type
bash / zshwc -l notes.txt

More in From bash and From cmd.

Related commands