Try this code:
Code:
alias countlines {
  if (!$0) return
  var %f = 0, %i = 0
  while ($read(test.txt,w,$1-,%i)) {
    %i = $calc($readn + 1)
    inc %f
  }
  return %f
}


Usage:
$countlines(*wild*)

Example:
//echo -a $countlines(*DC*)

Result:
Returns number of matching lines.

-genius_at_work