recursive grep
Leo de Wit
leo at philmds.UUCP
Tue Sep 12 20:49:41 AEST 1989
In article <15560 at duke.cs.duke.edu> bet at orion.mc.duke.edu (Bennett Todd) writes:
|The original poster asked for a straightforward construct to let him run
|a "find . -type d ..." invoking "grep {}/*" for each directory found.
|Other worthwhile suggestions have been offered which probably work
|better for what he probably had in mind; however, I am surprised no one
|mentioned the straightforward
|
| find . -type d -print | while read dir;do
| grep string $dir/*
| done
|
[]
I don't know whether the original poster (who?) posted his question too
to comp.unix.questions, 'cause quoting myself:
|From leo Fri Sep 8 12:56:11 MET DST 1989
|Article 14005 of comp.unix.questions:
|Path: philmds!leo
|>From: leo at philmds.UUCP (Leo de Wit)
|Newsgroups: comp.unix.questions
|Subject: Re: find cannot find all files in a directory
|Keywords: find files directory
|Message-ID: <1082 at philmds.UUCP>
|Date: 7 Sep 89 05:53:20 GMT
|References: <874 at wubios.wustl.edu>
|Reply-To: leo at philmds.UUCP (Leo de Wit)
|Organization: Philips I&E DTS Eindhoven
|Lines: 13
|
|In article <874 at wubios.wustl.edu> david at wubios.wustl.edu (David J. Camp) writes:
||I want find to return all the files in each directory to exec. That is,
||I want to do something like:
||
|| find /path -type d -exec command {}/\* \; -print
||
||so that command will be run on each file, one directory at a time.
|
|If you don't have xargs, how about:
|
| find /path -type d -print|while read dir; do command $dir/*; done
|
| Leo.
|
So there _was_ prior art, Bennett, though you'll probably have missed it.
Leo.
More information about the Comp.unix.wizards
mailing list