PowerShell article

Brian Grossman brian.grossman at gmail.com
Thu May 12 19:55:47 MDT 2022

Indeed json does require more parsing, but it's a standard and well
supported format.  The semantics represented by the json are arbitrary, but
at least the parsing is handled.

The tree|jq vs find example I gave just used the tool I had at hand to
demonstrate json output.  It's a poor example, unless you're trying to
teach people to not overthink a problem.  Thank you for the correction, and
fwiw even though I could have jq do the sorting, I would likely just pipe
it through sort anyway.  I still love the freedom of piping arbitrary data
around, and even torturing it with awk.

Are you familiar with xpath?  JQ's syntax reminds me of that, but a bit
saner.  You're welcome for nightmares brought forth by the mention of xpath.


On Thu, May 12, 2022 at 6:19 PM Bob Proulx <bob at proulx.com> wrote:

> Hi Brian,
> Brian Grossman wrote:
> > Imagine bash friends with an option for more structure than arbitrarily
> > formatted text.  I would occasionally like an option to emit json from
> many
> > commands in order to avoid parsing.  As a poor example:
> >
> >     tree -Jp -L 3 | jq -r '.. | objects | select( .type? == "file" ) |
> > .name | select( test( "[.]ini$" ))'
> >
> > is kinda-sorta-almost equivalent to
> >
> >     find -maxdepth 3 -type f -name \*.ini
> It is equivalent to  this though.
>     find . -maxdepth 3 -name '*.ini' -printf "%f\n"
> Note that to make them reproducible we would need to sort the outputs
> to ensure they have the same sort order for comparison.  "| sort" for
> both of them would be good.
> Since I don't work with jq everyday I find that set of commands
> mystifying.  I am sure it would make sense if I were to use it more.
> But isn't the json one requiring much more parsing?
> Bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.nclug.org/pipermail/nclug/attachments/20220512/545c22d2/attachment.htm>

More information about the NCLUG mailing list