Random assorted GnuAwk recipes

Counting lines after a given pattern occurs for the first time:

BEGIN { x = 0; f = 0 } 
/$PATTERN/ { f = 1 } 
{ if ( f == 1 ) { x ++ } } 
END { print x "\n" }
where $PATTERN is the pattern to search for. This is useful with long 'todo lists' for batch processes, as if you know the current job, this will tell you how many are left.