LJ Archive

Listing 2

BEGIN {
   # (1)
   FCOUNT=0
   COUNT=0
   TYPE="fruit:"
}
{
   # (2)
   if(length($0) == 0) next
      # (3)
      ++COUNT
      # (4)
      if($1 == TYPE) {
      ++FCOUNT
      print
  }
}
END {
# (5)
   print
"================================================="
   printf "%d out of %d entries were of type %s.\n",
   FCOUNT, COUNT, TYPE
}
LJ Archive