grep, etc
Bill Campbell
bill at celestial.com
Wed Aug 18 10:02:25 PDT 2004
On Wed, Aug 18, 2004, Bob Stockler wrote:
>On Wed, Aug 18, 2004 at 11:07:34AM -0400, Bob Stockler wrote:
>|
>| I would guess that "mawk" would be faster than "grep" in certain
>| circumstances, especially when searching a large file, because
>| it could be made to exit after reading the lines to be matched.
>
>Example:
>
> [trebor] ~bob: time grep '^factory$' /usr/dict/words
> factory
>
> real 0m0.11s
> user 0m0.06s
> sys 0m0.01s
> [trebor] ~bob: time mawk '/^factory$/{print;exit}' /usr/dict/words
> factory
>
> real 0m0.06s
> user 0m0.01s
> sys 0m0.00s
The ``mawk'' script cheats as it exits when it finds a match while grep
passes the entire file.
Bill
--
INTERNET: bill at Celestial.COM Bill Campbell; Celestial Software LLC
UUCP: camco!bill PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/
``Independent self-reliant people would be a counterproductive anachronism
in the collective society of the future where people will be defined by
their associations.'' 1896 John Dewey, educational philosopher, proponent
of modern public schools.
More information about the Filepro-list
mailing list