Date: Tue, 20 Jun 2000 04:23:47 +0200 From: Bernd Luevelsmeyer <bernd.luevelsmeyer@heitec.net> To: David Vondrasek <david@davidv.net> Cc: questions@FreeBSD.ORG Subject: Re: grep / zgrep help Message-ID: <394ED5B3.FE250B26@heitec.net> References: <200006191448.SM00167@pop.sby.globalinfo.net> <200006200100.UAA07480@ns1.davidv.net>
next in thread | previous in thread | raw e-mail | index | archive | help
David Vondrasek wrote: > > Im trying to create a search tool to locate text on a CD. The directory > tree is very *deep* > I know the basic zgep expression to grep one file or " * " for all files, > even add a -r to get the full tree.. But geezzz this takes almost an hour > for the full tree when All I need is one file in each directory to be > searched.. Can any one help with a expression line here ? > > Here is what I have now and the output goes to a webpage. [...] > The ONLY file that needs to be look at in each tree is the " billing.gz " > file. > > I need to be able to issue a command in > /cdrom/mail/radius/ > > and have it JUST searcjh though the billing.gz files in each subtree below. > This should cut my search time to about 1/20 of the time it does now with [...] The key commands are 'find' and 'xargs'. Use find to get the interesting filenames and xargs to launch zgrep on as many of them as possible. I think you should be using a variation of: find /cdrom/mail/radius -type f -name 'billing.gz' | xargs zgrep -e "whatever" /dev/null That's all in one line, in case my mailer splits it. /dev/null is there to protect from the case that only one filename ends up in the zgrep command line (zgrep's output would be differently). It may need some tweaking, I'm not sure it's working properly in every case or if it's really optimal. Have fun, Bernd To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?394ED5B3.FE250B26>