[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grep question



>
> On Tuesday, Dec 7, 2004, at 20:49 US/Central, Charlie Brune wrote:
>> How about:
>>
>>      find -type f -exec grep -H "this_string" \;
>>
>> The "-H" grep option will show the name of the file.
>
> Just being picky: you need to specify a directory and the argument to
> grep:
>
>   $ find . -type f -exec grep -H "this_string" {} \;
>
> Also, if I did use 'find', I would use xargs instead of the -exec:
>
>   $ find . -type f -print0 | xargs -0 grep -H "this_string"
>
> but that's just my preference.
>
> Regards,
> - Robert

On one hand...

   The directory is optional.  If not specified, it defaults to the
   current directory.

   Yes, I forgot the {} thingies.  8-)

   xargs is too hard for me to type in.  8-)  Let the computer do the
   work.  It's only electricity.

On the other hand...

   I TOTALLY didn't know about the "-r" option for grep!  It's the
   way to go!  I will never use the find command with grep again in
   my whole entire life!


(I know ... I need a life.)

Chas

-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.