Modern Linux Tools vs. Unix Classics: Which Would I Choose?
meetryanflowers.com
Modern Linux Tools vs. Unix Classics: Which Would I Choose?
1–10 of 61 posts
Re: Modern Linux Tools vs. Unix Classics: Which Would I Choose?
#2awk and friends are good tools to process text. Not JSON. A new field, or a format change, will thrash your brittle script contraption. Please use the right tool for each job.
Re: Modern Linux Tools vs. Unix Classics: Which Would I Choose?
#3Sure, maybe you get it working, after much pain. Then someone decides to format your input JSON a bit differently, and everything fails catastrophically.
This is the same problem described in the infamous answer "You can't parse [X]HTML with regex":
https://stackoverflow.com/questions/1732348/regex-match-open...
(Now, if you've been caught in a time-travel accident, and if you must parse JSON using classic Unix tools, consider using lex and yacc. They are sufficiently powerful to do the job correctly.)
Re: Modern Linux Tools vs. Unix Classics: Which Would I Choose?
#4Re: Modern Linux Tools vs. Unix Classics: Which Would I Choose?
#5I too can never remember jq syntax when I need to. I usually just end up writing a Python script to extract the part of the JSON I need.
Re: Modern Linux Tools vs. Unix Classics: Which Would I Choose?
#6I thought this was going to be about modern replacements for `ls` or `more`. Or maybe `ip` vs `ifconfig`. awk and friends are good tools to process text. Not JSON. A new field, or a format change, will thrash your brittle script contraption. Please use the right tool for each job.
Re: Modern Linux Tools vs. Unix Classics: Which Would I Choose?
#7Parsing JSON using 'cut' and 'awk' and 'sed' sounds like the jankiest thing ever. Sure, maybe you get it working, after much pain. Then someone decides to format your input JSON a bit differently, and everything fails catastrophically. This is the same problem described in the infamous answer "You can't parse [X]HTML with regex": https://stackoverflow.com/questions/1732348/regex-match-open... (Now, if you've been cau…
Re: Modern Linux Tools vs. Unix Classics: Which Would I Choose?
#8It's just a matter of experience with the toolchain.
You only have to be cautious when your input is mangled in some way (with escape characters etc) and your toolchain cannot cope with such things.
There are many different versions of cut, awk, sed and even jq. I don't consider this very portable.
Re: Modern Linux Tools vs. Unix Classics: Which Would I Choose?
#9I thought this was going to be about modern replacements for `ls` or `more`. Or maybe `ip` vs `ifconfig`. awk and friends are good tools to process text. Not JSON. A new field, or a format change, will thrash your brittle script contraption. Please use the right tool for each job.
Re: Modern Linux Tools vs. Unix Classics: Which Would I Choose?
#10I too can never remember jq syntax when I need to. I usually just end up writing a Python script to extract the part of the JSON I need.
gron transforms JSON into discrete assignments to make it easier to grep for what you want https://github.com/tomnomnom/gron
Miller is like awk, sed, cut, join, and sort for data formats such as CSV, TSV, JSON, JSON https://github.com/johnkerl/miller