4 ms·
> cat somefile.txt | sort | uniq > output.txt, in cmd.exe type somefile.txt | sort /unique > output.txt or in powershell type file.txt | sort -unique Powe
by com2kid 8y ago
> cat somefile.txt | sort | uniq > output.txt,
in cmd.exe
type somefile.txt | sort /unique > output.txt
or in powershell
type file.txt | sort -unique
Powershell is obscenely powerful, it is equal to anything Bash can do plus:
1. It sends objects instead of streams, so instead of relying on fixed width output and string splitting, you can specify which column(s) of output you want from a tool directly
2. It can pull data from all sources of sources, including databases, WMI, COM sources and more.
3. Fully plugged into automation for servers, rich auto-complete, and a native ecosystem that is designed to all work together.
4. It can call into .NET libraries
But even cmd.exe can handle outputting text and sorting it!
- novaleaf 8y agomy problem with powershell is that cmd.exe based workflows are not compatable, and it's workflows are sufficiently different from bash/cmd to make me avoid learning it. Why spend a few days learning pwsh if I can just use cmd now and move on to my next task.
- com2kid 8y agoYeah that's why I'm also still on cmd.exe. Every time I've dove into Powershell, wow, impressed, but I have over 2 decades of experience with cmd.exe!
- dublin 8y agoBecause even though you can do most things in cmd, it's just never been a very good tool? CMD is a bad tool that we learned to use b/c we had no choice (w/o loading an add-on scripting env of some kind). PowerShell has a learning curve, and I've delayed learning it for many years, but now is the time to do it, esp now that it's open-sourced and available on more and more Linux distros...
- ernst_klim 8y ago>Powershell is obscenely powerful, it is equal to anything Bash can do plus: Yeah, modern shells should stop pretending that everything is text. That's ridiculous. Powershell is doing a good job here. As for power, powershell is to weak compared to Python or Ruby, too few libraries and fancy stuff, at least on unices. Maybe it could compete with Racket, but Racket is a much nicer language IMHO.
- dublin 8y agoAgreed - Since MS has open-sourced PowerShell, it really should get picked up and used by more folks in the Linux community - it seems like its mostly decades of bad blood preventing that, even though it's a clearly superior 21st century approach. My allegiance is to great tools, and I'm learning PowerShell b/c of this...
- lenkite 8y agoThe concepts around Powershell are good. But the language is a nightmare and simple things like the short-circuit operator are completely broken.
- majkinetor 8y agoIf you use aliases then its not nightmare. Use aliases, they are the same as on linux and even better (you can deduce them from the full name by standard). > short-circuit operator are completely broken. What do you mean ? This kind of thing ?: > 0 -and (Write-Host 2) False > 1 -and (Write-Host 2) 2 False Not typically used in PowerShell, its bash paradigm IMO. There are objects here, so we throw error objects mostly and combine lines differently.
- lenkite 8y agoUnfortunately, outputting the boolean result makes "and" rather useless. See https://github.com/PowerShell/PowerShell/issues/3241 https://github.com/PowerShell/PowerShell/issues/3241