[svlug] Re: [svlug]how to copy a bunch of "." files?

Jeffrey B. Siegal jbs at quiotix.com
Sat May 6 18:07:14 PDT 2000

Joey Hess wrote:
> You can't count on that, xargs can only pass so many arguments to a
> command at once, so if you were grepping 1001 files and it decided to
> only pass in 1000 arguments at a time, it would run:
> grep foo 1 2 ... 999 1000
> grep foo 1001
> Any matches found by the second grep would not be prefixed by the
> filename. If you want to ensure filename prefixing, just use grep
> --with-filename

The traditional way of doing this (also useful when using a legacy grep
missing the --with-filename option) is 

    find ... -print | xargs grep pattern /dev/null

Also, the find -print0 and xargs -0 options are useful to properly
process file with names containing spaces:

    find ... -print0 | xargs -0 grep pattern /dev/null

(don't think legacy greps have this though)

More information about the svlug mailing list