in bash scripts, using set -x
to emit all of the commands that are being executed (and turning it off with set +x
). Lets you quickly figure out what is wrong with the script.
Neat! I love single purpose shell utilities composes with other commands (“do one thing well”). I like that this also plays nicely with jq
, which is one of my favorite tools.
For me, small, standalone binaries like this are where golang shines brightest. I created a cmdline tool called ganda
(https://github.com/tednaleid/ganda) that can take thousands of piped urls and it’ll download them all in parallel and pipe the results on stdout to something like jq (or save to a file). I think the json output of tj
might fit well with this, I’ll give it a shot.
Gron! It transforms JSON into greppable lines like
path.to.items[3] = value
, and if you like you can edit the result and use gron to transform the edited stuff back to JSON. This brings JSON structures into the line-oriented sed/grep/awk universe – I’m looking at you, Jupyter notebooks. I’ve only had gron for a few months, and it’s already my 13th-most-used command.Example output (gron can read from stdin, files, and even URLs):
Thanks for mentioning this! I had no idea this existed, but is definitely in line with how my brain works vs
jq
. Even though I usejq
almost daily, I can never remember some of the syntax.I created an alias for
jq
, calledjqpath
, that leveragesfzf
to give searchable output similar to gron, but that emits it injq
’s expected format: https://twitter.com/tednaleid/status/1302477635914739713Oh wow, I just noticed @mrcruz’s recommendation of xml2, elsewhere on this page, which does something similar for HTML and XML. Although for HTML I had hoped it would include element classes and IDs in the path —
.../div/div/...
is not useless, but.../div.comment#c_tez5vc/div.details/...
would have provided more orientation points. Still, this is going in my toolbox; and I thought you might like it, too.Part of the output of
curl https://lobste.rs/s/eprvjp/what_are_your_favorite_non_standard_cli | html2
: