[Novalug] bash commands

Richard Rognlie rrognlie at gamerz.net
Fri Jan 18 14:51:17 EST 2008


Some systems have rgrep, but in the absense of that...

cd WHEREVER

then either
        find . -name \*.f -print0 | xargs -0 grep 'string' /dev/null


since not all unixes support print0 in their finds, you might have to 
resort to the following instead,

        find . -name \*.f -print | xargs grep 'string' /dev/null


(why /dev/null?   just in case grep gets invoked with a single filesname
argument, this adds a 2nd filename... which will cause grep to report
which file matched)



On Fri, Jan 18, 2008 at 02:30:14PM -0500, Nino Pereira wrote:
> Hi you bash experts,
> 
> I'd like to search all the files in a directory
> for the occurrence of a particular
> string. It must be something like
> 
> do (until you have had all the files)
>   cat *.f | grep --with-filename 'string'
> od
> 
> but I don't have an example to modify from. Can you point me
> to one?
> 
> Thank you,
> 
> Nino
> _______________________________________________
> Novalug mailing list
> Novalug at calypso.tux.org
> http://calypso.tux.org/cgi-bin/mailman/listinfo/novalug

-- 
 /  \__  | Richard Rognlie / Sendmail Ninja / Gamerz.NET Lackey
 \__/  \ | http://www.gamerz.net/~rrognlie    <rrognlie at gamerz.net>
 /  \__/ | Creator of pbmserv at gamerz.net
 \__/    |                Helping reduce world productivity since 1994


More information about the Novalug mailing list