39 ms·
In PowerShell, PS> Import-Csv .\names.txt -Header name | group name | select name, count Name Count ---- ----- cat 3 dog 2
by kuma4 10y ago
In PowerShell,
PS> Import-Csv .\names.txt -Header name | group name | select name, count
Name Count
---- -----
cat 3
dog 2
mouse 1
bird 1
- latkin 10y agoSeriously, the author seems to have fairly limited knowledge of powershell. A 13-line python script is presented, followed by a smug "you can almost hear the UNIX folks complain about how verbose the PowerShell version is". First off, the provided Unix commands _don't work_ (should have used `sort -rn -k 2`), while the provided powershell, as verbose as it is, does work. Second, the entire python script along with the wrapping unix commands is encapsulated with a powershell 1-liner: cat ./names.txt | group | sort -d Count