On 09/13/14 16:05, Allan West wrote:
On 9/13/14 3:11 PM, Robert Hajime Lanning wrote:
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.
On 09/13/14 16:32, Steve VanDevender wrote:
> Which is why you should use
>
> find ... -print0 | xargs -0 ...
>
> which cases'find to use '\0' instead of '\n' to terminate printed
> items, and causes 'xargs' to parse its input correspondingly.
Ya, I probably should have pointed out the "-print0" and "-0" args in my
command line example, instead of just leaving it to the reader to
actually do research...
I always use "-print0" and "-0". It has become habitual. Of course it
screws me up, when I am not on a GNU based system. Which, thankfully,
has become more and more rare. :)
--
Mr. Flibble
King of the Potato People
http://www.linkedin.com/in/RobertLanning
_______________________________________________
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/