I was in the process of downloading Cygwin to in order to get the wc command (among others) in order to do some file verification work. I stopped for a second and thought why not use PowerShell? I found a good source for this so here is the command:
PS C:\Scripts\AMA> gc test.134.* | Measure-Object
Count : 395587
Average :
Sum :
Maximum :
Minimum :
Property :
Notice that I'm using gc as an alias for Get-Content. gc, type and cat all work as aliases for Get-Content.
test.134.* is just a typical DOS file mask to get all files that start with test.134.
Now let's get a word count:
PS C:\Scripts\AMA> gc test.134.23.00 | Measure-Object -word
Lines Words Characters Property
----- ----- ---------- --------
8391
How about a character count:
PS C:\Scripts\AMA> gc test.134.23.00 | Measure-Object -char
Lines Words Characters Property
----- ----- ---------- --------
1670774
How about an explicit line count:
PS C:\Scripts\AMA> gc test.134.23.00 | Measure-Object -line
Lines Words Characters Property
----- ----- ---------- --------
8391
Keep in mind that Measure-Object can also be used with objects but we'll save that for another post. Also it might be nice to try to create a nice short alias like wc to save me some typing.