Fast file scan

Paul John Falstad pfalstad at phoenix.Princeton.EDU
Fri Sep 28 06:43:01 AEST 1990


In article <2165 at van-bc.wimsey.bc.ca> jtc at van-bc.wimsey.bc.ca (J.T. Conklin) writes:
>In article <299 at lysator.liu.se> pen at lysator.liu.se (Peter Eriksson) writes:
>>I`d like to know how to scan all files in a directory (and it's sub-
>>directories) for a specific string (without regular expressions) as fast
>>as possible with standard Unix tools and/or some special programs.
>>
>>(Using the find+fgrep combination is slooooow....)
>I have found that find+xargs+fgrep to be quite reasonable when I need
>to perform such a task as yours.   Are you possibly ommiting the xargs,
>thus forcing find to exec a fgrep for each file?

I agree that find+xargs should do the job, but fgrep...  On our system,
at least (SunOS 4.1) the 'f' in fgrep does NOT stand for fast.  fgrep is
designed to grep for one or more Fixed strings.  egrep is actually the
fastest if you have a lot of input.  I just tested fgrep and egrep by
making a file consisting of 42 copies of /usr/dict/words and grepping
for the string 'dictionar'.  egrep did it in 1/8 the time of fgrep.

If Lafontaine's elk would spurn Tom Jones, the engine must be our head, the
dining car our esophagus, the guardsvan our left lung, the kettle truck our
shins, the first class compartment the piece of skin at the nape of the neck,
and the level crossing an electric elk called Simon.



More information about the Comp.unix.misc mailing list