On 9/13/14 3:11 PM, Robert Hajime Lanning wrote: > On 09/13/14 11:51, Doug Hughes wrote: >> FWIW: this is a perfect use case for xargs instead of exec. You'll save >> a lot of fork/clone system calls and simplify your find. Brandon pointed >> out the main problem, but consider this alternative: >> >> find . -name '*.cs' -print -o -name '*.c' -print -o -name '*.h' -print | >> xargs grep file-io.c >> > > I have run into issues with "-print" and "xargs"... spaces in filenames... > Doesn't happen much when dealing with source code (.c .cs .h), but it happens > a lot when dealing with music and documents from Windows/Mac users. > > find . \( -name '*.cs' -o -name '*.c' -o -name '*.h' \) -print0 | xargs -0 > grep blah > > :) >
Ah, then you need -print0 and xargs -0, which is why I love xargs. If you "man find", in the section about "-X" the last few lines describe their use together: -X Permit find to be safely used in conjunction with xargs(1). If a file name contains any of the delimiting characters used by xargs(1), a diagnostic message is displayed on standard error, and the file is skipped. The delimiting characters include sin- gle (`` ' '') and double (`` " '') quotes, backslash (``\''), space, tab and newline characters. However, you may wish to consider the -print0 primary in conjunction with ``xargs -0'' as an effective alternative. _______________________________________________ Tech mailing list Tech@lists.lopsa.org https://lists.lopsa.org/cgi-bin/mailman/listinfo/tech This list provided by the League of Professional System Administrators http://lopsa.org/