This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


>>>>> "David" == Karr, David <david.karr@cacheflow.com> 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.
alcocer@helixdigital.com -- http://www.helixdigital.com

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]