Skip to content

Latest commit

 

History

History
executable file
·
29 lines (19 loc) · 722 Bytes

count-characters-words-and-lines-in-a-file.md

File metadata and controls

executable file
·
29 lines (19 loc) · 722 Bytes

Count Characters Words And Lines In A File

Category: Windows

You can count the number of characters, words, and lines in a file using PowerShell.

Count the number of characters:

Get-Content some-file.txt | Measure-Object -Character | select-object -ExpandProperty Characters

Count the number of words:

Get-Content some-file.txt  | Measure-Object -Word | select-object -ExpandProperty Words

Count the number of lines:

Get-Content some-file.txt  | Measure-Object -Line | select-object -ExpandProperty Lines

Count everything showing the output in table format:

Get-Content some-file.txt  | Measure-Object -Character -Line -Word