PowerShell Quick Tip- Letter Frequency
With a list of Surnames in a text file I wanted to see how many start with A, how many with B, and so on. This is my PowerShell solution:
1(Get-Content .\surnames.txt).Substring(0,1).ToUpper() |
2Sort-Object | Group-Object |Select-Object Name, Count
Example Input (surnames.txt
file):
1Adams
2Smith
3Jones
4Bloggs
5...
Example Output:
1Name Count
2---- -----
3A 162
4B 372
5C 365
6D 193
7E 187
8F 198
9G 154
10H 321
11...