Hacker News new | ask | show | jobs
by kuma4 3589 days 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
1 comments

Seriously, 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