Subject: Re: Recursive grep (where is limfree defined?)
To: None <current-users@NetBSD.ORG>
From: None <>
List: current-users
Date: 01/23/1996 01:15:50
> > I found this patch today on the FreeBSD hackers mailing list.  It patches
> > the grep source to allow recursive searches.  Compared to the find method
> > shown above, it is about 3-4x faster.
> how does it compare to:
> 	find /usr/src/sys -name "*.c" | xargs grep '^limfree' /dev/null

In this case, the above find is a bit quicker, but the recursive grep has to 
look though every file, not just the .c files.  A fairer comparison, for 
general searching purposes, would be:
        find /usr/src/sys - name "*" | xargs grep '^limfree' /dev/null
In this test, recursive grep is a little faster.

> i think i'd best describe a patch that does that as ...
> architecturally challenged, and not just a bit against the spirit of
> what grep is 'supposed' to do.

What is "spirit" of grep anyway - searching files for a matching 
pattern?  Should it matter that those files are in subdirectories?  
Should anyone care?

I don't think a recursive grep is any worse than a recursive chown or 
chmod.  You can accomplish all three with using 'find xargs', but it is more 
convenient to let the command take care of it.  

As for the architecturally challenged statement, I would be surprised if 
it didn't work on all of the supported platforms, since it uses NetBSD's 
built-in file traversal functions.  

> the find ... | xargs ... is:
> 	(2) is portable to any POSIX system,

How many different systems are we concerned with?  I can only think of 
1...  :)

> 	(3) is more flexible (both because of find's flexibility, and
> 	    because you can do a lot with a pipeline).

This is true.  But find ... | xargs ... can't be argued to be more 
intuitive than grep, and certainly not easier to use.  

> why build unnecessary (and, in my opinion, dumb) functionality into
> grep?

Because everyone knows grep, but not everyone knows 'find xargs grep'
(Even people who do know 'find xargs' don't always do it the most efficient 
way, as we have seen). For a very small chunk of code, you add a lot of 
functionality that everyone can use.  

How dumb do you think the "limfree guy" thinks a recursive grep is?  Or
most average users, for that matter.  

If we don't add the recursive grep, we should at least add the appropriate
example to the find(1) man page - not that the average joe user would
think to look there.  However, he probably would look at grep, and
wonder why it can't do what he wants it to!

In short:  Unix wizards might despise the idea of a recursive grep, but 
it is something that everyone else really needs and could use.  

Jeff Thieleke