PowerShell article
Bob Proulx
bob at proulx.com
Thu May 12 18:19:05 MDT 2022
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
More information about the NCLUG
mailing list