My blog recently saw a small spike of visits. Where it usually sees like two dozen visits a day, the numbers jumped last saturday to around 100 per day without any reason that I could recognize.

Yesterday I learned that my post about the wonderful "jq" tool made it into the shownotes of an podcast episode[1]. I didn't even know this podcast before....



As I was able to recommend the tool to @aral today, I updated the post a little bit to add some useful information.

jq has become a valuable tool for me and I will show in an upcoming blog post how a one-liner in jq is able to add fields to an XML file. Before I "found" this oneliner, I tried with awk and XSLT but even though I got them to work, the solutions offend my aesthetical perception.

The jq oneliner is pure beauty in comparison.

· · Web · 1 · 0 · 1

But I also have to admit that writing jq programs is more difficult for me than I expected, especially programs that transform data rather than only selecting pieces of it.

For anyone interested, the one-liner in question adds symbols to waypoints contained in a valid GPX file:

xq -x '.gpx.wpt[] += {"sym":"Pin, Red"}' export.gpx > export-w-pins.gpx

There are a lot of attributes in the XML document that need to be preserved and I was always looking for jq instructions to pass on everything I am not interested in. Simply not mentioning this was the biggest mental hurdle for myself.

In hindsight, this looks so obvious, but it took me literally hours to work out.

Sign in to participate in the conversation | Hostsharer im Fediverse

Die Mastodon-Instanz bietet den Mitgliedern der Hostsharing eG eine gemeinsame Heimat im Fediverse. Diese Instanz wird von der Hosting-Genossenschaft Hostsharing eG betrieben.