4 ms·
Of course one any of those filenames contains a space, your first two examples break down, and in the worst case result in the wrong files being deleted. Of cou
by BlackFingolfin 10y ago
Of course one any of those filenames contains a space, your first two examples break down, and in the worst case result in the wrong files being deleted. Of course one can work around that, but in reality, this quickly gets difficult, and often is forgotten. The print0 works for some cases, but not in general (e.g. when one needs to do more complex processing)
- leni536 10y agoThe second example is fine, to be fair. {} is replaced by a single argument, no shell magic here.
- milesrout 10y agoThe second one doesn't fail, and the first one only fails because I wrote `rm $file` instead of `rm "$file"`, which I have done every single other time I've written the same thing this century.
- uzoodoo 10y agoWriting in first one won't save you since "in" splits by whitespace, not newline. If you really have to do that, use "find ... | while read file; do" instead.