News for hackers. Stuff that matters.
Re:Problem solving with Unix commands by voltagex_ on Thursday February 14, 2019 @06:28PM (#19167090)
I have never been able to get my head around awk - how did you learn it?
Re:Problem solving with Unix commands by yesenadam on Saturday February 16, 2019 @10:10PM (#19182469)
Same as usual, read every book about it![0] and don't try to learn from the man page. I think the original book by A, W and K (the 2nd edition anyway) was best. Also Arnold Robbins' books Sed and Awk and Effective AWK Programming are great.

The GNU Awk User's Guide[1] is amazingly detailed, but the new AWK has bloated a lot, has 1000 features where the older one had a few dozen, and those core ones should be learnt first. (But people still like programming with it, and kept asking for features..) Hmm I don't think I use any of the new features, maybe I should...

But really, it's very simple, I can't thinking of anything that's been anything like as easy to learn, except maybe BASIC. With which AWK shares some similarities - the friendliness of it, the BEGIN and END..

[1] http://www.gnu.org/software/gawk/manual/gawk.html

[0] Or if there are too many, get names from lists of best books on a subject.

Re:Problem solving with Unix commands by yesenadam on Monday February 18, 2019 @12:24AM (#19188805)
p.s. Bruce Barnett's AWK guide may be helpful, I've learned a lot from him on various UNIXy subjects.

http://www.grymoire.com/Unix/Awk.html

Re:Problem solving with Unix commands by FelipeCortez on Thursday February 14, 2019 @06:32PM (#19167114)
The AWK programming language book is excellent!

https://archive.org/download/pdfy-MgN0H1joIoDVoIC7/The_AWK_P...

You can find some discussion about it here: https://news.ycombinator.com/item?id=13451454

Re:Problem solving with Unix commands by voltagex_ on Friday February 15, 2019 @12:00AM (#19168559)
>This book was typeset in Times Roman and Courier by the authors, using an Autologic APS-5 phototypesetter and a DEC VAX 8550 running the 9th Edition of the UNIX operating system.

Delightful!

Re:Problem solving with Unix commands by patrec on Thursday February 14, 2019 @06:52PM (#19167233)
"The AWK programming language" has already been suggested and is great.

But awk is actually pretty simple. Imagine everything having an implicit loop like this around it like so:

  # BEGIN{ ... } would go here
  for $0 in input.split('\n'):
      $1, $2, ... = line.split()
      # if TEST {ACTION}; pairs ...
  # END { ... } would go here
      
so the first TEST in GP's awk would be `$1 ~ /class|module/` and the corresponding ACTION to take `{print $2}`.

if TEST is omitted it's True, if ACTION is it's print the whole line.

Re:Problem solving with Unix commands by svsucculents on Saturday February 16, 2019 @11:33AM (#19179363)
It's C. Learn C and you know awk. The only awk worth using is G(nu)awk anyway.
Re:Problem solving with Unix commands by msla on Saturday February 16, 2019 @08:19PM (#19182017)
No, in that C doesn't have the pattern-action style of awk:

    /<pattern>/ { <action> }
"For every line which matches <pattern> perform <action> " is the fundamental flow of awk programs. It's procedural but the iteration is hidden; it's almost like each stanza is a callback which gets executed when the pattern fires. I'm kinda surprised no "real language" has adopted this design for an API.