On 03/25/1999 10:31 -0500, Timothy J Luoma wrote:
Replying to message of Wed, 24 Mar 1999 12:01:46 -0600
from Tim Walberg <walberg(_at_)cig(_dot_)mot(_dot_)com>
regarding ``Re: Message count''
> Not 100% bullet proof, but try
> cat ${MAILFILE} | grep '^From ' | wc -l
Heh... where's that Useless Use of cat Award ?
The same thing can be written
grep '^From ' ${MAILFILE} | wc -l
which is slightly more efficient.
TjL
Sigh... After recieving a few of these smart-ass flames (ok,
so they're little flames, but still...). That particular
example was meant to be rather verbose, but clear.
It clearly delineates the three steps involved: 1) read
the file, 2) search for a patterh, 3) count the matches.
I fully realize there are more (and less) efficient ways
of accomplishing the same task. Optimization for a particular
application is, as they say, left as an exercise for the
reader. Are you willing to guarantee that every implementation
of grep supports the -c option? Maybe it does, but I
tried to show an example that made as few assumptions as
possible...
Anyway, I'll quit wasting bandwidth that can better be used
for other things...
tw
--
+--------------------------------------+------------------------------------+
| Tim Walberg | Phone: (847) 632-3407 |
| Motorola CE/ITS | Pager: (800) SKY-TEL2 PIN:1384689 |
| 1475 W Shure Dr. IL75-2H14 | FAX: (847) 632-5769 |
| Arlington Heights, IL 60004 | |
+--------------------------------------+------------------------------------+
| http://www.cig.mot.com/~walberg | E-mail:
walberg(_at_)cig(_dot_)mot(_dot_)com, |
| http://www.skytel.com/Paging (pager) | 1384689(_at_)skytel(_dot_)com
(pager) |
+--------------------------------------+------------------------------------+
pgpMUtvgguCCW.pgp
Description: PGP signature