home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
cmplangm
/
1989_6
/
awk
/
walk.awk
< prev
next >
Wrap
Text File
|
1988-03-05
|
1KB
|
47 lines
# Prepare a formatted listing of
# all occurances of a given keyword
# in a file
BEGIN {
pagesize = 16
outlines = 0
NR = -1;
}
outlines % pagesize == 0 && length(lines) != 0 {
# new page initialization
# print the page header
printf "\n Pages and lines where awk occurs\n"
printf " Page Lines\n"
printf " ____ _____\n\n"
outlines = 6
newoutpage = 1
}
/awk/ { # if the string "awk"
# occurs in the current record
occurances++
pageno = int (NR / 66) + 1
lineno = (NR % 66) + 1
if (lines == "") {
pages = pageno
lines = lineno
}
else if (pages == pageno && length(lines) < 40)
lines = lines ", " lineno
else {
printf "%5d %s\n",pages, lines
outlines++
pages = pageno
lines = lineno
}
}
END {
if (lines != "")
printf "%5d %s\n", pages, lines
printf "\n%d occurances of awk\n", occurances
}