Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Point taken, but there's nothing prohibiting commands from outputting their data in a different text format that's better suited for tree-like data (like JSON), and another set of minimal commands which processes JSON-formatted data - easy extensibility by the user is also part of the "UNIX philosophy".

That's also the point where I'd reach for Python or Deno/TS to write such command line tools, because both Bash and C are not really well suited for text processing - and neither are the traditional UNIX tools like sed or awk IMHO.



JSON would be better, true, but PowerShell actually has objects, so dates are actually dates and not just a string containing a date. So you can actually do timezone conversions and calculations on what you get directly, rather than having to feed the date string into a parser.

But yeah, JSON would be a good start. But for some reason there seems to be little interest even in that. Wouldn't it be nice to have `df --json` or `mount --json`?

And that makes me sad, because the system could be so much better if it moved forward a bit instead of being stuck in the 80s.


Honest question: How do you do discovery on PowerShell objects?

That is, with the Unix approach, when I'm trying to do something ad hoc I can do one step of a pipe, read the results on the terminal, see what the format is, and figure out how I have to set up the next step of the pipe. How do I do that with PowerShell?


Pipe it through Format-List:

    C:\Windows> Get-Item .\explorer.exe | Format-List
This gives you the generally useful view of what Get-Item returned. You can ask to see everything with:

    C:\Windows> Get-Item .\explorer.exe | Format-List -Property *

Tab completion also completes these. Some of what you get can be subdivided further if you look, eg:

    C:\Windows> (Get-Item .\explorer.exe).VersionInfo.FileVersionRaw | Format-List -Property *


Use Get-Member. For example, to find all available properties of the service object:

     Get-Service | Get-Member
Also, Format-List and ConvertTo-Json can show you a lot of details




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: