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

This is so much easier with Powershell. V7 is totally cross-platform and I cant see why people have a problem to use it, if nothing else then for `ConvertFrom/To-Json/CSV/Whatever` cmdlets ..


I'd love to see an example. Let's say I'm on a Debian server. How would I acquire Powershell (is it GPL/MIT?) and use it to convert some JSON?


Powershell Core and .NET core are MIT Licensed as of 2016 https://github.com/PowerShell/PowerShell/blob/master/LICENSE...

Debian install instructions https://docs.microsoft.com/en-us/powershell/scripting/instal...

Enable https, add feed, apt install

As someone who started out scripting in Powershell but preferred Linux as an OS. I found myself missing powershell's object passing in opposition to bash's string passing.

That being said I now primarily use iPython for advanced shell tasks as I can leverage all of Python's libraries like JSON or YAML.


> That being said I now primarily use iPython for advanced shell tasks as I can leverage all of Python's libraries like JSON or YAML.

TBH they're both excellent choices. nushell looks really good too. The point is not to scrape text - rather than write a bash script that can handle JSON properly, write a pwsh/python/nushell script that handle everything properly (ie, by selecting fields rather than scraping text).


Yeah, lets wait 10 years for nushell to catch up.


Terrific, thank you!


You'd install it via apt obviously. For Ubuntu:

    curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
    sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-jessie-prod jessie main" > /etc/apt/sources.list.d/microsoft.list'
    sudo apt-get update
    sudo apt-get install -y powershell
I'm a node developer, here's what I used to find packages that had a cracked dependency recently:

    $results = @{} 
    ls -recurse -filter "eslint-scope" | foreach { 
      $file = "${PSItem}\package.json" 
      $version = cat $file | convertfrom-json | select -ExpandProperty version 
      $results.Add($file,$version) } 
    echo $results | format-list
PS. pwsh should really combine reading a file, determining it's type, and parsing it, into one command. Like:

    open $file | select -ExpandProperty version 
I know I can make this, it just should be in the stdlib.


As someone fairly ignorant of Powershell, how well does it interact with the rest of the Unix-minded ecosystem? jq is nice because its plainly compatible with being piped into another command like xargs. I don't want a better jq if it means relearning and remastering everything else along with it.


The same as any other CLI app.

> I don't want a better jq if it means relearning and remastering everything else along with it.

As I said, better jq may be equal to:

pwsh -Command "(cat test.json | ConvertFrom-Json).Whatever.Property.Or.Normal.Filter"




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

Search: