I added the print0 option (and the -0 flag to xargs) so that it will treat a path with spaces in properly - otherwise you would get:
Code:
~ $ ls
My File My Document
~ $ find . -name *Document -print | xargs -n1 echo rm
rm My
rm Document
(I haven't tested the example, I'm on Windows atm, but the issue is that spaces in filenames can lead to unintented behaviour)
-n1 is a personal preference. It means pass them one argument at a time, so:
Code:
~ $ find . -name * -print0 | xargs -0 echo rm
rm file1 file2 file3 file4
~ $ find . -name * -print0 | xargs -n1 -0 echo rm
rm file1
rm file2
rm file3
rm file4
I just find the second more readable, especially when you've got a long filepath.
Certainly in zsh, 'rm' doesn't prompt you for every file without the '-f' flag, I think it's only the ones without write permission or something similar. If you know what you're doing, then your command is fine.
Your commands are both fine as far as I can see, though I would add back the -print0 and -0 flags on the first one.
The only reason I thought your 'rm' commands were 'wrong' was because you said
Quote:
They are in many subfolders of a folder.
|
which suggested to me that if you were executing this in, e.g. ~/folder, you might want to delete ~/folder/subfolder/file.html
Your rm commands won't find this, as they will only be looking for files in ~/folder, not ~/folder/subfolder. If this is wrong, then your commands are fine, I'd just remove the '-r' flag from the *.html and *.htm rms, as you don't need it 'cos you're deleting files not directories.
Hope this helps,