Or don’t, I’m not your father.
The situation Sometimes, you want to get a very specific part of a command output. The classic problem is to get the IP address of an interface. Even today, the results to these queries on your favorite search engine will most likely involve grep, sed, awk and the like.
But what if I told you there’s a better way?
Using JSON for structuring data Some tools offer outputting their data in JSON format. That data can be processed with the venerable jq utility. The control you have over the processing is higher and the chance that the data format of the output changes is lower. Let’s look at what that means in practice.
Ha!
jq
was the bratty kid I yelled at to get off my lawn. Now he’s a drinking buddy, but still the youngest!It’s true that compared to the other utilities, it’s rather new. First release was almost 13 years ago.
awk
, which I think is the closest comparison, on the other hand turns 50 in 2027… though new awk is only 40.