by kuma4 · 10y ago · 0 comments
PS> Import-Csv .\names.txt -Header name | group name | select name, count
Name Count
---- -----
cat 3
dog 2
mouse 1
bird 1A 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