by alkonaut · 9y ago · 0 comments
Example: count the number of files of each extension in the current direcory and list the results alphabetically by extension (I honestly didn't pick this as a way to show of PS strength and I realize that you can always pick a benchmark that shows what you want - but I wanted something small and understandable).
PS:
ls | group Extension | sort Name | select Count, Name
bash: ls | awk -F . '{print $NF}' | sort | uniq -c | awk '{print $2,$1}'
These lines accomplish the same thing, with about the same amount of typing required. You can argue that objects are brittle too,
or that text is a universal format whereas objects are not. But you can't tell me the bash line looks better, or that for everyday tasks PS is always a verbose mess.
Also: just typing the bash line on my keyboard includes hitting Ctrl+Alt/AltGr eleven times!The set based paradigm of SQL lends itself very well to reporting and processing files, and is known by 7 million people.
SELECT extension, count(*) FROM files GROUP BY extension ORDER BY extension;
We built a tool, free for personal use, that does SQL at the command line
Unless the underlying model has all of that, I don't see how it competes with bash/ps
It should be doable but requires more than a filesystem relational model
Select * from processes order by priority
I mean I see the benefit of using Sql, had I mastered it, for files, but I'd be reluctant to sort and group reg keys or users or devices or processes or env vars differently from files in my shell language. You must have a "relational model" for the file system, do you have a way to (or plan to) generalize this to general structured data?
One of the great things about a Linux system is that you can use the terminal to install and delete programs. Can you do that with PS without using something like Chocolatey?
You can also download and install Windows installer setups from a shell, and also uninstall them e.g by name (more elegantly in PS than in cmd). Because win apps are usually binary this is a more common way than the "make install" equivalent on Linux (Where I don't believe there exists a distro independent binary installer format?)
You can't install apps like "packages" without a package manager like choclatey, but that I assume is the same in Linux, you need to install a package manager like apt or yum if the distro didn't come with one.
Still pretty meat that you can uninstall a program from PS. Might need to give it a closer look, any suggestions on where to learn it from?
The big difference between something like Chocalatey and rpm/deb Linux package ecosystems is more one of scale (how many packages exist in the ecosystem; how many players are expected/required to buy into the ecosystem).
An interesting twist to this is that PowerShell in Windows 10 'recently' added a meta-package manager "OneGet" that was designed to use a single set of commands to learn to work with a wide collection of package ecosystems (including, but not limited to, Chocolatey, NuGet, MSI installers, Docker packages, whatever other sort of provider someone wants to build).