#!/usr/bin/awk -f BEGIN {wordCount=0; longestLine=""; beginsWithAnd=0;} { if($1 == "And") { beginsWithAnd++; } print $0 > "temp"; if(system("grep -i nevermore temp") != "") { print "\nLine with nevermore: " currentLine; } if(wordCount < NF) { wordCount = NF; longestLine = $0; } } END { print "\nLongest line: " longestLine; print "\nWord count: " wordCount; print "\nBegins with AND: " beginsWithAnd; }