Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Imagine for a second that the DB can't do it and you need to filter the STDOUT output.


That doesn't sound hard at all. AWK, anyone?


Writing awk to do it is definitely more work than calling obj.Property though.


  $mysql_cmd|awk -F\| '$2 == "what you want the second row to match" {print $0}'
Not that much more work. And you can do better if you can coax mysql to emit proper DSV.


That kind of stuff adds up fast in an interactive shell.


...Which is why you write a script to do it if it comes up often.

Extendable tooling!


Okay, I've imagined it. It does seem terrible.

Fortunately, that's not a world any of us live in.


Er, it's a world all of us live in. Say, for example, ‘ps’ or ‘ls -1l’.

Then you end up using awk, which is rather like a half-assed version of powershell to work around shortcomings with the unix everything-is-a-string design.


AWK isn't a workaround. It's a tool for processing tabular data, in a textual format. The fact that it can solve so many problems is actually a strength of the EIAS design.


Parent comment was talking about parsing the raw output from a database in stdout. That's what I was responding to, and I'm not wrong.


OK, but now imagine it's not a database, because there are programs that do act this way.


And those programs usually emit proper CSV. You could use regex to match on what you want, but AWK was literally built for this. It's fantastic, it works great, and if you don't use that tool that was built to solve your problem, that's your own lookout.


I don't think awk is actually capable of parsing CSVs in all cases.


It doesn't parse escapes, IIRC, but those are rarely emitted.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: