Iterate through directories and search into files

Mel fbsd.questions at rachie.is-a-geek.net
Fri Sep 26 12:32:20 UTC 2008


On Friday 26 September 2008 14:22:27 Steve Bertrand wrote:
> Steve Bertrand wrote:
> > Hi everyone,
> >
> > I have a list of directories:
> >
> > - a..z and 2003..2008
> >
> > ...inside of a single directory.
> >
> > Can someone advise what the shortest shell pipeline would be to search
> > for two words (on two separate lines) within all files located only the
> > alpha directories, and then print the filename to STDOUT?
>
> ...what I meant to say was that both patterns will be on the SAME line,
> as a single instance example, I would do:
>
> cat a/file.fil | grep -i comment | grep 355

find ./[a-z]* -type f -exec grep -il 'comment.*355' {} +


-- 
Mel

Problem with today's modular software: they start with the modules
    and never get to the software part.


More information about the freebsd-questions mailing list