News for hackers. Stuff that matters.
Re:Marcel the Shell by Too on Tuesday October 24, 2023 @01:04AM (#37994989)
Using the output of find into another program is not safe due to risk of file names containing delimiters. You need to use find -exec.

Good example of why machine readable output is important. Agree that the tutorial should showcase more and larger such examples.

Re:Marcel the Shell by rmwaite on Tuesday October 24, 2023 @01:09AM (#37995016)
You can always use -print0. I suppose there is some risk of a null slipping into a filename but I’ve never come across it myself.
Re:Marcel the Shell by gnosek on Tuesday October 24, 2023 @01:28AM (#37995095)
> some risk of a null slipping into a filename

Only in some fairly esoteric environments: https://en.wikipedia.org/wiki/Filename#Comparison_of_filenam...

Re:Marcel the Shell by js2 on Tuesday October 24, 2023 @01:51AM (#37995222)
Yes, I know that, but it's also exceedingly rare for a filename to contain a newline and using -exec is extremely inefficient. I also wrote that on my iPad. Typically I'd use a combination of -print0 and xargs -0 for anything more formal than a one-liner on the command line.

The larger bug in my example is that it fails if any of the directories in the path contain a "." in their name!

Re:Marcel the Shell by eviks on Tuesday October 24, 2023 @03:18AM (#37995724)
So then why are you using such buggy examples as counterarguments?
Re:Marcel the Shell by js2 on Tuesday October 24, 2023 @04:02AM (#37996021)
It's one example. I didn't realize the mistake when I wrote it. I wrote my comment in good faith. What's with the interrogation?
Re:Marcel the Shell by queuebert on Tuesday October 24, 2023 @09:29AM (#37998922)
xargs also is good to use on big argument lists because it can parallelize the processing of arguments with the '-n' and '-P' flags.