News for hackers. Stuff that matters.
Re:Awk vs. Perl (2009) by CalChris on Tuesday June 27, 2017 @02:57PM (#14648181)
When I need to do something like this I usually use sed. It's similar enough to vim that I don't have to remember too much. I've never liked perl at all and awk doesn't offer that much more than sed. Maybe that'd be different if this sort of wrangling was a steady diet but it isn't. If I was gonna use awk I'd just skip straight on through to python.
Re:Awk vs. Perl (2009) by kazinator on Tuesday June 27, 2017 @06:17PM (#14650070)
> awk doesn't offer that much more than sed

Not much; just, oh, stuff like floating-point math and trig functions; integer math, associative arrays, access to environment variables, named functions with arguments and full recursion; control and looping structures like if, for and while, file I/O and redirection, string literals with C escapes, ...

  $ awk '$0=sin($1) + cos($2)'
  0 1
  0.540302
  1 0
  1.84147
How about sed?

Just kidding ...

Re:Awk vs. Perl (2009) by CalChris on Tuesday June 27, 2017 @06:45PM (#14650245)
Holy double angle formula, Batman. Awk has command line trig functions? Riddle me this. Is the Google search bar just an Awk script and they won't tell you? That's just the sneaky kind of trick L+S would try.
Re:Awk vs. Perl (2009) by majewsky on Tuesday June 27, 2017 @03:53PM (#14648765)
> awk doesn't offer that much more than sed

The one huge thing that sed is particularly bad at (unless I don't know the particular trick yet) is to split fields on a pattern. I frequently have pipes where sed is used for most of the text-processing, but then cut is used to select one (or multiple) character-separated fields, or awk is used to select one (or multiple) whitespace-separated fields. I only go one step further (usually to Perl) when operations involve multiple lines, e.g. when columns need to be summed up.

Re:Awk vs. Perl (2009) by vram22 on Tuesday July 04, 2017 @02:01PM (#14697320)
>awk doesn't offer that much more than sed

Wrote this earlier in this same thread:

https://news.ycombinator.com/item?id=14648534