I think people with this attitude would be really pleasantly surprised by PowerShell and Cmder. Windows makes a very bad UNIX, but it has a great command-line story these days if you'll play with it on its own turf.
Pleasantly surprised by powershell? I don't know what to say. I have to essentially copy and paste fragments of things that work, it's so arcane. Its like writing 90's Java on a command line. Its revolting.
> I have to essentially copy and paste fragments of things that work, it's so arcane.
I have about the same problem when it comes to bash. While bash may very well be described as "arcane" I believe this is mostly a problem of unwillingness to learn something new or different.
Understanding how PowerShell works takes a bit of time and re-thinking. It doesn't help that there's so much downright bad PowerShell code out there that was mindlessly converted from VBScript. Still, it's not that hard and the language is quite consistent and, well, powerful. They made quite a large effort to make sure that the underlying concepts are orthogonal and pervasive throughout. So learning just a few concepts actually make a very large part of the shell and language approachable and easy to understand.
Fair point. PowerShell is three things, actually: An embeddable scripting runtime, a scripting language, and a shell. The latter is (by name, probably) what people see it as, usually. Furthermore, most usage examples throughout the web use it for things that are traditionally done in a shell, e.g. interactive use, or small scripts that mainly do filesystem maintenance stuff.
You're right in that Python may be a more apt comparison, especially in that PowerShell's .NET foundation serves as the equivalent to Python's included libraries.
But that's a discussion that would have to happen every time people try to think of PowerShell as a weird bash. And it is a capable and useful shell, too. It just can do a lot of things much better than bash; they just look different.
When powershell comes up, someone always gripes about how they can't do this or that like they can in bash. I'm not going to deny that grep is nicer to use that the powershell equivalent (Select-String). But you don't configure Windows and other software in the Microsoft ecosystem by messing around with text. For example, if you had a new user and you wanted to set up an account, email address, and phone number (so AD, Exchange, and Lync/Skype for Business in Microsoft land), it wouldn't just be hard using something like Cygwin, it would probably be impossible. There is just no way to talk to those programs text streams or config files.
I guess what I always want to know when people complain about powershell is what they were actually trying to do. I think it's an excellent tool for system administration in a Microsoft environment. When you start moving away from that use case, it gets less and less useful.
the problem with powershell is that it is incredibly stupid if you're not on a full windows stack (desktops, servers and near enough to everything inbetween) and running the most recent version of windows (ever tried getting winrm installed and reliably working on a 2008 box?)
perhaps if they were not too opposed early on to horrible open source things and just one of the languages that already fit fairly well in that area (python for example) they wouldn't have had to go out of their way to make pretty shitty hacks (i really wonder if anyone in the powershell\winrm team did any testing or development with the machines more than 10 metres away)
Yeah, PS remoting is basically a no-go before server 2012, and even then it's just barely functional enough to be occasionally useful. They're planning on adding SSH support though, so I'm cautiously optimistic.
I don't think something like Python would have been a good choice to use instead of PS. While I'm sympathetic to the complaint that PS is more of a programming language than a shell, that's even more true of Python. I use PS as a shell far more often than I use it for complicated scripting, and as much as I like Python, I just can't see using it as a shell.
I suspect you haven't read the documentation or tried using PowerShell for any length of time. PowerShell may be bash-like, but it's not bash, does not try to be bash, and won't reward you if you treat it like bash. But it's very orthogonal, clean, and well documented.
For your particular example:
> help grep
Name Category Module Synopsis
---- -------- ------ --------
Out-File Cmdlet Microsoft.PowerShell.U... Sends output to a file.
Select-String Cmdlet Microsoft.PowerShell.U... Finds text in strings and files.
Okay, so Select-String sounds really promising. Let's take a look.
Most of those command flags seem really straightfoward to me. Can you be more specific about what was unclear to you? I'd be happy to help.
EDIT: BTW, it's a bit annoying to type Select-String, so it'd be nice if it had an alias. Does it have one?
Well, you can get aliases in PowerShell by typing alias. But that'll give you a wall of text; what you want to do is to quickly search for things that are aliased to Select-String.
There are two ways to do this. First, you can pipe to a GUI that allows directly filtering the results:
> alias | out-gridview
Or, alternatively, we can figure out what objects alias gives us:
> alias | select -first 1 | get-member
Note that we've got a Definition field, and query on that:
> alias | Where-Object { $_.definition -contains 'Select' }
which is a long version of
> alias | ? { $_.definition -contains 'Select' }
And notice that Select-String is aliased to sls by default. Note that I can just reference the column by name, rather than going through some awk/cut fun.
You might be annoyed that Select-String is not aliased to grep. While many commands actually do have multiple aliases to both DOS and Unix equivalents (e.g., Get-ChildItem is aliased to gci, dir, and ls, and Remove-Item has ri, rm, and del as aliases), Select-String works differently enough from grep that it's not a default alias so you're not confused.
Fair enough, and I have and will continue to not really want to invest time into learning Microsoft's stuff, based on past experiences (my first being wanting to develop for the platform as a scrub, and they charged thousands of dollars for a dev environment/compiler). I honestly don't think it'll serve me well going forward, when there are better alternatives.
They have had decades now to get on board with developers, and cmd.exe is still their go-to console. They still strike me as a company of greedy corporate business folk, who happen to run a software company, as opposed to a software company that has to suffer greedy corporate drones to survive in our current race to the bottom.
Correct - it has a couple of crippling features, such as wrapping output at 80 characters even if piped to a file (unless you tell it otherwise every time).