Recursive grep question

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Ravi Parimi
Date:  
Subject: Recursive grep question
> Setup:
> -Directory tree
>    top
>     |--sub1
>     |--sub2
>     \--sub3
> -Each of the subX directories have *.c files in them.
> -The top directory does NOT have any *.c files in it.
> -I am currently in the top directory.

>
> Goal:
> -Find the string "foobar" every place that it occurs in the *.c files in
> all of the subX directories.
>
> Command and result:
> [adayley@locatlhost top]$ grep -ir foobar *.c
> grep: *.c: No such file or directory
> [adayley@locatlhost top]$


I dont think you can pass filename wildcards to grep if those files dont
exist in the current directory. A quick test returns the same error to
me..

How about trying find coupled with xargs?

find . -type f -name '*.c' -print |xargs grep -i foobar



HTH,
--ravi