home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / cmplngmg / cl_jun89.arc / AWK210.ARC / WALK.AWK < prev    next >
Text File  |  1988-03-05  |  1KB  |  47 lines

  1.                                 # Prepare a formatted listing of
  2.                                 # all occurances of a given keyword
  3.                                 # in a file
  4.  
  5. BEGIN {
  6.         pagesize = 16
  7.         outlines = 0
  8.         NR = -1;
  9. }
  10.  
  11. outlines % pagesize == 0 && length(lines) != 0 {
  12.                                 # new page initialization
  13.                                 # print the page header
  14.  
  15.         printf "\n Pages and lines where awk occurs\n"
  16.         printf " Page        Lines\n"
  17.         printf " ____        _____\n\n"
  18.  
  19.         outlines = 6
  20.         newoutpage = 1
  21. }
  22.  
  23. /awk/ {                         # if the string "awk"
  24.                                 # occurs in the current record
  25.         occurances++
  26.         pageno = int (NR / 66) + 1
  27.         lineno = (NR % 66) + 1
  28.         if (lines == "") {
  29.                 pages = pageno
  30.                 lines = lineno
  31.         }
  32.         else if (pages == pageno && length(lines) < 40)
  33.                 lines = lines ", " lineno
  34.         else {
  35.                 printf "%5d        %s\n",pages, lines
  36.                 outlines++
  37.                 pages = pageno
  38.                 lines = lineno
  39.         }
  40. }
  41. END {
  42.         if (lines != "")
  43.                 printf "%5d        %s\n", pages, lines
  44.         printf "\n%d occurances of awk\n", occurances
  45. }
  46.  
  47.