Found in 5 comments on Hacker News
generic_user · 2016-02-08 · Original thread
[edit] keep in mind this is just a simple example. Awk is just one tool in the toolbox.

Take a look at 'The AWK Programming Language ' Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger.

http://www.amazon.com/The-AWK-Programming-Language-Alfred/dp...

Yes, its that Aho and Kerninghan...

operators to C function mapping. you can run like so.

$ awk -f fixed.awk < fixst.in > fixed.c

--- fixed.awk ---

  BEGIN {
  	printf("#include <stdio.h>\n");
  	printf("typedef long fixed;\n");
  	printf("void *send(fixed *this, char *message, ...);\n");
  }
  /^{/ { 
  	Ndecl = 0;
  	printf("{\n");
  }
  /^}/ { 
  	while(--Ndecl >= 0)
  		printf("\t%s\n", Destructor[Ndecl]);
  	printf("}\n");
  }
  /^:/ {
  	if($2~/fixed/) {
  		sub(/;/, "", $3);
  		printf("\tfixed *%s = send(NULL, \"fixed\");\n", $3);
  		Destructor[Ndecl++] = "send(" $3 ", \"~fixed\");"
  	}
  	else if ($4 ~ /(double)/) {
  		sub(/;/, "", $5);
  		printf("\tsend(%s, \"double\", &%s);\n", $5, $2);
  	}		
    	else if ($3 ~ /^=/) {
     		sub(/;/, "", $4);
    		printf("\tsend(%s, \"=\", %s);\n", $2, $4);
    	}
    	else if ($3 ~ /^\+/) {
    		sub(/;/, "", $4);
  		printf("\tsend(%s, \"+=\", %s);\n", $2, $4);
  	}
  	else if ($3 ~ /^\*/) {
  		sub(/;/, "", $4);
  		printf("\tsend(%s, \"*=\", %s);\n", $2, $4);
  	}
  }
  /^[^{}:]/ { print }
--- fixst.in ---

  int main()
  {
  :	fixed a;
  :	fixed b;
  :	fixed t0;
  :	fixed t1;
  	double f;
  :	a  = 1.00;
  :	b  = 9.99;
  :	t0 = 0.00;
  :	t1 = 2.00;
  :	t0 += t1;
  :	t0 *= b;
  :	t0 += a;
  :	f  = (double)t0;
  }

sea6ear · 2015-01-15 · Original thread
Also Awk has one of the best bite sized tutorial/references out there. Up there with Programming in Lua in terms of awesomeness per page count.

http://www.amazon.com/AWK-Programming-Language-Alfred-Aho/dp...

bcantrill · 2014-05-28 · Original thread
Not an accident -- I'm a well-known awk lover, and it was very much an inspiration for DTrace. (Even down to the documentation: if you haven't read it recently, re-read "The AWK Programming Language"[1] -- it's beautifully concise.)

[1] http://www.amazon.com/The-AWK-Programming-Language-Alfred/dp...

iradik · 2011-07-26 · Original thread
Between cat, cut, grep, sort, join, uniq, tr, and awk there is so much data processing one can do with text files if only one has:

  1. some text files to process,
  2. the patience to read through their man and info pages,
  3. and a healthy appreciation of unix philosophy.
For learning awk at the highest level, the man page will not be enough, and I suggest reading this book: http://www.amazon.com/AWK-Programming-Language-Alfred-Aho/dp...

Fresh book recommendations delivered straight to your inbox every Thursday.