For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > November 2005 > Recursive patter search in UNIX









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Recursive patter search in UNIX
vijay_v_g@rediffmail.com

2005-11-18, 7:01 pm

I'm looking at getting list of files that contain certain patter say
"ABC". How to do that? I tried using "find. |grep "patter"

Pascal Bourguignon

2005-11-18, 7:01 pm

vijay_v_g@rediffmail.com writes:

> I'm looking at getting list of files that contain certain patter say
> "ABC". How to do that? I tried using "find. |grep "patter"


find . -name \*ABC\* -print
or:
find . -name '*ABC*' -print


--
"Specifications are for the weak and timid!"
Jim Cochrane

2005-11-18, 7:01 pm

In article <87u0ea3p1d.fsf@thalassa.informatimago.com>, Pascal Bourguignon wrote:
> vijay_v_g@rediffmail.com writes:
>
>
> find . -name \*ABC\* -print
> or:
> find . -name '*ABC*' -print
>


I think the OP meant to search for the pattern within the contents of each
file - e.g.:

find . -type f -exec grep -l '\<ABC\>' {} ';'

--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
Chris Friesen

2005-11-18, 7:01 pm

vijay_v_g@rediffmail.com wrote:
> I'm looking at getting list of files that contain certain patter say
> "ABC". How to do that? I tried using "find. |grep "patter"


How about something like

grep -rs "pattern"

alternately,

find . |xargs grep "pattern"

Chris
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com