grep, etc
Bob Stockler
bob at trebor.iglou.com
Wed Aug 18 10:00:50 PDT 2004
On Wed, Aug 18, 2004 at 12:17:32PM -0400, 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
And just to read the entire file searching for a non-existing
line in it:
[trebor] ~bob/Mail: time grep '^xfactory$' /usr/dict/words
real 0m0.07s
user 0m0.04s
sys 0m0.02s
[trebor] ~bob/Mail: time mawk '/^xfactory$/' /usr/dict/words
real 0m0.01s
user 0m0.00s
sys 0m0.01s
The file size (and time to determine it) is shown by:
[trebor] ~bob/Mail: time wc /usr/dict/words
23739 23739 194186 /usr/dict/words
real 0m0.02s
user 0m0.01s
sys 0m0.01s
Bob (Stockler the timer)
--
Bob Stockler - bob at trebor.iglou.com
Author: MENU EDIT II - The BEST Creator/Editor/Manager for filePro User Menus.
Fully functional (time-limited) demos available by email request (specify OS).
More information about the Filepro-list
mailing list