[Cialug] Find Files with String

Brandon Gray graybrandon at gmail.com
Fri Dec 11 17:06:21 CST 2009


find <path> -type f -exec grep -l mystring {} \;

On Fri, Dec 11, 2009 at 11:09 AM, Josh More
<morej at alliancetechnologies.net> wrote:
> Or grep -rl "string" /  :)
>
> It would, however, be wise to do as others have suggested and exclude
> /dev/, /proc/, /sys/ etc.
>
> Grepping /dev/zero might take a while.  ;)
>
>
>
> -Josh More, RHCE, CISSP, NCLP, GIAC
>  morej at alliancetechnologies.net
>  515-245-7701
>
>>>> Todd Walton  12/11/09 11:04 AM >>>
> On Fri, Dec 11, 2009 at 10:51 AM, Josh More
> <morej at alliancetechnologies.net> wrote:
>> Yep.
>>
>> grep -r "string" /
>
> The problem there is that it prints the matched lines as well.  I want
> just the names.
>
> I could put that output into cut though.  That's it!
>
> grep "string" * | cut -d: -f1 -s
>
> --
> Todd
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>


More information about the Cialug mailing list