Re: Like grep? sed? awk?
>>"It's simpler and orders of magnitude faster. Stat has loads of options to give you information on just about anything about a file."
Granted, it's significantly faster, but I was actually being kind to the GNU/Linux version by using my version. I've never said anything about comparable speed, I was responding to someone who said that Powershell had inconsistent outputs and unmemorable names. What I'm doing is pointing out what a terrible choice of attack they had made. xargs highlights like nothing else the inconsistency of the GNU/Linux versions. I'll illustrate, but first I'm going to clear something up because you're making false assumptions:
>>You might find [...] easier because you're used to it, but Linux administrators would see "find", "xargs", "stat", "sort", and "uniq" to be familiar to them.
I started out on UNIX and have worked professionally on UNIX or Linux for over a decade. I didn't even start using Windows until Windows 7. It is nothing to do with familiarity, I'm saying that the Powershell version is more intuitive and consistent. Getting back to proving that, just look at your attempt to solve the problem vs. the Powershell attempt:
DIR -Recurse | Get-Acl | Select-Object Owner | Select -Unique
find . -print0 | xargs -0 stat -c "%U" | sort | uniq
(I'm happy to use your preferred example, btw)
Each step of the Powershell one is almost self-explanatory (ACLs are permissions on Windows) and they connect via a straight-forward pipe in each case because they all use objects. In the Linux version you're now using the fiddle of xargs to deal with the fact that stat can't have output of find pushed directly to it. You have to pass the stat command as a parameter to xargs so it can use it as some sort of call back. That's not consistent nor memorable (the charges that were levelled at Powershell). You accused me of letting familiarity affect my judgement (I did not, I've actually used Bash and GNU tools far longer than I have Powershell), why don't you look at all the little things you've thrown in without much thought that trip up new people:
-0 parameter to xargs. You've thrown that in to tell xargs that the input list is terminated by nulls, not whitespace. Something which is hardly intuitive or easy to remember.
-print0 parameter to find. Otherwise it will terminate each output with a newline so you have to use a special switch to get it to terminate with nulls so that it will fit with the next item in your pipeline.
-c switch for stat followed by "%U" to format the output as just usernames. Why does a utility for getting file parameters come with its own built in formatting tool? In Powershell, you get an object output which you pass to a dedicated formatting tool. Want your output as a table? No problem - you don't have to change the previous item in the pipeline based on what the later one wants, you just pass the object array on to the Format-Table cmdlet which will have access to all attributes of the file object. It's consistent and it is more importantly the separate stages of the pipeline are discrete, not having to look forward to later stages in the pipeline.
xargs was, honestly, a terrible example to pick. Yes it is faster than my own example significantly (and about 10% faster than the Powershell one though it's harder to do a like for like comparison there so take that as unscientific). HOWEVER, it is a wonderful example of the inconsistency of the GNU/Linux version. It exists purely as a work around for the fact that you're handling everything with text and different command handle piping in different ways. Neither is true on Powershell.
>>"I have to admit though that you've come up with a unique way of solving the problem. I doubt that I would have ever thought of trying it that way."
Well the argument is about memorability and consistency, so I was trying to come up with a way that just illustrated the differences between Powershell and Bash / GNU tools and my example is a bit clearer with regards to what is actually going on. It's not faster than using stat, nor shorter in terms of characters. But it's simpler for someone to understand which is what we're comparing the environments on so it's actually fairer to GNU/Linux, imo.
Bash and the GNU tools evolved over time and never had consistent oversight of design. People just added whatever doohickey they happened to need as they needed it. Just look at how find has its own built in print tools (which use different formatting instructions to printf). find has had everything people wanted rolled into it at some point. Whereas Powershell follows the UNIX philosophy of do one thing and do it well. Perhaps more significantly, the GNU/*NIX environment grew up before OO was big. Powershell is a modern design, planned out and designed to that plan, with the opportunity to learn from all its predecessors mistakes and for a mature OS (came in with Windows 7 and integrates fully with .NET). Are you not open to the possibility that it might be better than Bash?