3 ms·
No it won’t, because none of the output is interpreted as an argument. It’s passed as lines to grep. The second invocation correctly uses print0 and pairs with
by CGamesPlay 2y ago
No it won’t, because none of the output is interpreted as an argument. It’s passed as lines to grep. The second invocation correctly uses print0 and pairs with xargs to understand this.
Now, it does fail with filenames that have newlines in them, but who would do such a thing!
- natmaka 2y agoI wrote "Not always perfectly right" thinking about all cases, not this particular one: in nearly all cases (bar being absolutely sure there is no blank character anywhere) -print0 (and therefore xargs -0) seems better to me, and it sure saved me on many occasions. Better let "find" do all the work it can, including filtering filenames.
- usr1106 2y agoIf you run this interactively on your own files, saying who would do such thing is fine. If your server code runs this on untrusted input (files uploaded by users or whatever), the answer will be: Someone trying to crack your system.