Recipies:
*Count lines in a file
Count number of lines in all Java files:
> type *.java | Measure-Object -line
Lines Words Characters Property
----- ----- ---------- --------
1240
Deconstruction:
type *.java prints the content of all files matching *.java pattern
Measure-Object -line counts number of lines
You can also count words and characters with Measure-Object -line -word -character.
Count number of files:
> (ls *.go | measure -line).Lines
13
Deconstruction:
ls lists files in the directory
measure is an alias for Measure-Object
.Lines extracts just the Lines property from result of measure cmdlet, for shorter output