4 ms·
Your comment ignores the major integration that PowerShell does provide: .NET. PowerShell can invoke any .NET code and work with the objects returned therefrom.
by jdmichal 10y ago
Your comment ignores the major integration that PowerShell does provide: .NET. PowerShell can invoke any .NET code and work with the objects returned therefrom. Yes, it has terrible integration with text-based tools, because it's not a text-based shell. It has great integration with the .NET object-based environment, because it's a .NET object-based shell.
(This is also completely ignoring the fact that you can still call any executable; you'll just receive a bunch of strings back. The only failing here is that PowerShell doesn't have the developed string-manipulation tools like sed, awk, etc. because working with text is typically unnecessary.)
- qwertyuiop924 10y agoYes, and on most platforms, .net has fairly weak integration.
- jdmichal 10y agoIf your sole argument is that .NET has weak integration on platforms for which version 1.0 of the core runtime was only released two months ago, then I don't really have anything to add. Of course it's going to have a weaker integration than a tool set that has existed and been developed together for decades. However, your original argument was more along the lines of PowerShell being a walled-garden of cmdlets. Which is patently wrong -- it works with any .NET code. It also works with the standardized structured text formats of CSV, JSON, and XML. It does not currently have tools to work with the two-dimensional text structures typically found on *nix machines, because until this week it was not even available in those environments. We might very well see creation of tools to ease this process.
- wolfgke 10y agoThis is a problem of most platforms.
- jodrellblank 10y agoThe only failing here is that PowerShell doesn't have the developed string-manipulation tools like sed, awk, etc. because working with text is typically unnecessary.) What kind of tools does it not have? It has all the .Net style string methods (split, trim, and so on), all the .Net regex methods, built in arrays and hashtables, looping over lines of text shortcuts. It's pretty trivial to do small scale ad-hoc text parsing, cut lines by a character, take element 4, cast to 'datetime' and add +4 days to it, handwave a counter into existance and +1 it, match a regex and do some replacement or group some fields. It doesn't go as far as sed "in-place text replace" or awk records, but saying it "doesn't have developed string-manipulation like sed" is like saying that of Python. And if you were writing Python you wouldn't need to call out to awk because you'd just use Python string processing and basic data structures for what you were doing, right?
- qwertyuiop924 10y agoWell, if I was using Python to write a script better suited to AWK, I'd use AWK instead.
- jdmichal 10y agoI meant exactly that "it doesn't go as far as sed... or awk...". PowerShell has what I would term the primitives of string manipulation, inherited from .NET -- substring, trim, regex replace, etc. But it does not have the advanced methodologies that sed and awk provide. Especially in regards to editing, since PowerShell also inherits .NET's immutable strings.
- qwertyuiop924 10y agoThis. AWK is the best tool for record DSV record manipulation I've ever used. Some would say that it has since been surpassed by other scripting languages, but I disagree. It's fast to learn, and is incredibly good at what it does, with a very simple and elegant design. Simple AWK scripts can read like descriptions of what you want done. Like this script that prints all users in /etc/passwd that have home directories in /home: BEGIN{$FS=':'} $6~/^\/home.*/{print}