Subject: Re: 'find | xargs -n100 -i{} echo "{}"': works, but is slower than without "-i{}"
From: Dario Alcocer <[email-masked]>
To: "Karr, David" <[email-masked]>
Cc: "[email-masked]'" <[email-masked]>
Date: Fri, 22 Jun 2001 13:38:30 -0700

>>>>> "David" == Karr, David <[email-masked]> writes:

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

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

    David>    find . -type f | xargs -n100 -i{} grepf searchstring
    David> "{}" <...snip...>

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

Well, I don't know about more "efficient", but there is a better way:

    $ find . -type f -print0 | xargs -0 grepf searchstring

This command-line will use nulls instead of whitespace to separate the
filenames.  Refer to the manual pages for find(1) and xargs(1) for
more information regarding the -print0 and -0 options.  This approach
is what I use whenever I need to process files in the "C:\Program
Files" directory.

Hope this helps,

-- 
Dario Alcocer -- Sr. Software Developer, Helix Digital Inc.
[email-masked] -- http://www.helixdigital.com

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