Comment

Comment by layer8

It’s a pity that awk doesn’t support capture groups in line patterns. Then you could get rid of the field separator and make the script even more comprehensible. (You can simulate this with match() in gawk, but then you must know how match() works.)

Personally, I’d probably rather use sed here:

  sed -nE 's/^\s*name:\s*"([^"]*)"\s*$/\1/p"
While that regex is more complex, it is also safer and more explicit.
parent layer8 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton