'find | xargs -n100 -i{} echo "{}"': works, but is slower than without "-i{}"

Karr, David david.karr@cacheflow.com
Thu Jun 21 11:35:00 GMT 2001


I work on a project where some of the files and directories were created
with spaces in them.  That will eventually be rectified, but it's hard to
say when (we use a CM system that doesn't make this easy to deal with).

I often find that I have to do "find | grep" operations.  I realized I
couldn't get this to work unless I did something like this:

   find . -type f | xargs -n100 -i{} grepf searchstring "{}"

I use "-n100" to try to make it somewhat more efficient than starting a
process for each line, although I still need to pay attention to
command-line length limits.  The combination of '-i{}' and '"{}"' makes it
so that directories with spaces in them will be handled correctly.  Without
that, "grep" tries to search in the wrong directories (or nonexistent
directories, most likely).

This works.  However, I accidently discovered that using "-i{}" essentially
causes my "-n100" option to be ignored.  When I changed my "command" to just
prepend "echo" to the command line, I found it was executing one command for
each file, as opposed to one command for each 100 files.  This considerably
slows down my tree searches.

Is there any way to get back my more efficient command line, while still
working with my annoying "spacy" directories?

I was actually able to repeat this on both Cygwin and a Linux system, so
perhaps this is "defined" behavior.

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list