Originally posted by Cowboy Bob
find <directory_to_search_from> -print -name <wildcard> -exec grep <whattofind> {} \;
where <wildcard> is a pattern of the files you want to search, e.g. *.c (or for that matter fred.c if you only want to check files of that name).
On some versions of unix the file paths won't be printed unless you use the -print argument, although I think this is usually redundant these days.
(Needless to say none of the '<' or '>' symbols are redirects in the above.)
edit: On most unices these days the grep command has a -r option (for 'recursive', i.e. a treewalk a-la find)


Leave a comment: