find and grep

Hi,
I need to find out a particular pattern from a directory, for example say X.

The X directory contains 10 c files, and it has subdirectory called Y, and Y has 20 c files within it.

Now I have to find out the pattern only from parent directory X not from sub directory Y.

I have used this type of command

X> find . -name "*" | xargs grep -l "getsum"

It will retrive result from sub directory also.....I need only for the parent dir.

Thanks
Sarwan

then specify that in the find command itself

find X/ -name "*" | xargs grep -l "getsum"

X/ - the dir from where u want to search.

find X/ -name "*" | xargs grep -l "getsum"

This one also retrives pattern file name from the sub directory.

find X/ -name "" | xargs grep -l "getsum" it gives the same o/p as this
find . -name "
" | xargs grep -l "getsum".

Whether you give absolute or relative path, find drills down into all the subdirectories starting from the path specified.

So you may as well try out,

find . \( ! -name . -prune \) -type f | xargs grep -l "pattern"

"prune" prevents going into sub-directories.

X> ls *.c | xargs grep "getsum"