[TUHS] Tech Sq elevator (Was: screen editors) [ really I think efficiency now ]

Jon Steinhart jon at fourwinds.com
Sun Jan 19 04:45:28 AEST 2020


Michael Parson writes:
> On Mon, 13 Jan 2020, Dan Cross wrote:
> > 
> > [Resending as this got squashed a few days ago. Jon, sorry for the
> > duplicate. Again.]
> >
> > On Sun, Jan 12, 2020 at 4:38 PM Jon Steinhart <jon at fourwinds.com> wrote:
>
> <snip>
>
> >> Many people have claimed, incorrectly in my opinion, that this model
> >> fails in the modern era because it only works on text data.  They
> >> change the subject when I point out that ImageMagick works on binary
> >> data.  And, there are now stream processing utilities for JSON data
> >> and such that show that the UNIX model still works IF you understand
> >> it and know how to use it.
> >
> >
> > Certainly. I think you hit the nail on the head with the proviso
> > that one must _understand_ the Unix model and how to use it. If one
> > does so, it's very powerful indeed, and it really is applicable more
> > often than not. But it is not a panacea (not that anyone suggested it
> > is). As an example, how do I apply an unmodified `grep` to arbitrary
> > JSON data (which may span more than one line)? Perhaps there is a way
> > (I can imagine a 'record2line' program that consumes a single JSON
> > object and emits it as a syntactically valid one-liner...) but I can
> > also imagine all sorts of ways that might go wrong.
>
> And here, understanding the model is important, namely, grep is the
> wrong tool for searching/parsing JSON output. Dealing with JSON from the
> shell, you should use jq.  I've been dragged kicking and screaming into
> dealing with JSON, and about all I can say about it is, I like it about
> this >< much more than XML. :)
>
> -- 
> Michael Parson
> Pflugerville, TX
> KF5LGQ

Slight disagreement here.  I would say that grep is *a* a tool for JSON and
that jq is *a better* one.  The UNIX model part of this is that jq is another
tool in a toolbox and plays well with others.  What disturbs me about a lot
of software (and my tractor) it when it does the equivalent of throwing a
random metric bolt into something that's built from SAE hardware.

Jon



More information about the TUHS mailing list