• smeg@feddit.uk
    link
    fedilink
    English
    arrow-up
    14
    ·
    22 hours ago

    You can install powershell on Linux if you’re feeling masochistic

          • AMoistGrandpa@lemmy.ca
            link
            fedilink
            arrow-up
            3
            ·
            edit-2
            19 hours ago

            If you feel like learning a third shell, I find that Nushell is even easier to use than PowerShell.

            open stuff.json | each { get fieldName } | where { str starts-with "asdf" } | each { $in | str upcase }

            This gets all the objects in the given json file, then grabs the value of the field named “fieldName”, then filters all those values to find the ones that start with and, converts those to uppercase, and prints them to the screen as a nicely formatted list

            • AeonFelis@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              16 hours ago

              You don’t need the $in | in that last command. each { str upcase } will already pipe each item to the str upcase command.

          • ulterno@programming.dev
            link
            fedilink
            English
            arrow-up
            1
            arrow-down
            1
            ·
            16 hours ago

            Yeah, it does tend to be hard to determine when to use () {} [] etc.
            Even after I RTFM and used those in scripts multiple times, I tend to forget it by the time I need to implement something next.