On Wednesday 26 March 2008 13:29, Per Jessen wrote:
Randall R Schulz wrote:
On Wednesday 26 March 2008 13:08, Per Jessen wrote:
Istvan Gabor wrote:
...
How can I delete these files w/o removing the folder itself?
ls -1 .thumbnails/large/* | while read f; do rm $f; done
This is as slow as the find -exec approach and vulnerable to files with spaces and other special characters in their names.
Sigh. Allright, how about:
ls -1 .thumbnails/large/* | while read f; do rm "$f"; done
That's probably sufficient, though to be extremely nitpicky, Unix file systems allow newlines in file names. The use of the shell's "read" builtin cannot be made to accommodate that, while find with -print0 and xargs with -0 handle absolutely any file name that will ever appear on a Unix (or Linux or *BSD, etc.) system. And while people rarely create such things, they do sometimes come into existence (perhaps most often due to scripting errors!).
The find + xargs approach is still the best for circumstances like this.
Not without knowing the exact circumstances - it does work very well of course, but then so does my suggestion, given the right set of circumstances :-)
I'm not convinced. It's longer and harder to type (personally, I frequently mess up interactive input of shell control syntax, most often leaving out the "do" or "then" keywords, which just makes a mess of things). And while I don't know how many files need to be processed before the xargs approach significantly outstrips the iterated invocation rm approach, it is probably not all that many.
/Per Jessen, Zürich
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org