Path: utzoo!attcan!uunet!jarthur!elroy.jpl.nasa.gov!sdd.hp.com!zaphod.mps.ohio-state.edu!wuarchive!udel!princeton!phoenix!pfalstad From: pfalstad@phoenix.Princeton.EDU (Paul John Falstad) Newsgroups: comp.unix.misc Subject: Re: Fast file scan Message-ID: <2876@idunno.Princeton.EDU> Date: 27 Sep 90 20:43:01 GMT References: <299@lysator.liu.se> <2165@van-bc.wimsey.bc.ca> Sender: news@idunno.Princeton.EDU Distribution: comp Organization: Princeton University, Princeton, New Jersey Lines: 22 In article <2165@van-bc.wimsey.bc.ca> jtc@van-bc.wimsey.bc.ca (J.T. Conklin) writes: >In article <299@lysator.liu.se> pen@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.