Count lines in a file
suggest changeCount number of lines in all Java files:
> type *.java | Measure-Object -line
Lines Words Characters Property
----- ----- ---------- --------
1240
Deconstruction:
type *.javaprints the content of all files matching*.javapatternMeasure-Object -linecounts number of lines
You can also count words and characters with Measure-Object -line -word -character.
Count number of files:
(Get-ChildItem *.go | Measure-Object).Count
Measure-Object -Line does not count files. It counts lines in the text you pipe to it. .Count is the number of objects, which here is the number of matching files. ls is an alias for Get-ChildItem, and measure is an alias for Measure-Object.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents