If you run Linux and have been working with the filesystem(s) for any length of time, you have used and abused rm. However, when the number of files concerned is very large or there are unescaped characters in your filenames, rm can misbehave. The following code will take care of all your worries. The exec command always makes me stand back and wonder at the power of the Linux shell.
find . -name '*.*' -exec rm {} \;
From: http://howtos.linux.com/guides/abs-guide/moreadv.shtml
Also, Veen overhears an rm conversation
[EDIT] Be very careful using find to remove files.
Ok, that erases all your files with a dot in the name… What about “rm -rf .”?
Be very careful using find to remove files.
The find command by default is recursive so any and all files in all subdirs below the current directory will go away too.
Using ‘*.*’ for the pattern will miss all files without dots in them. rm is not able to remove the directories so you will get an error for each of them found (include ‘.’, the current dir).
If you really want to remove all files from the current directory through all it’s subdirectories and leave the dirs alone then the better find parameters would be:
find . -type f -exec rm {} \;
You could also use “find . -exec rm {} \;” and ignore the errors rm throws out for the dirs.
Very good advice indeed. My post was much more general but the link explains things further.
The best advice is to use the find without the rm to see what gets included before using the rm in the exec.
I posted about this a few days ago:
http://raybdbomb.com/p/argument-list-too-long.html
Try
find . -name ‘*.*’ -exec rm -rf {} \;
if you want to erase everything. Of course, I have yet to find a purpose for doing such except to be mean to *n*x newbies.
NOTE: This will erase everything – do NOT try.
If you’re converting from mod_php to phpsuexec on a cpanel system, the following commands help:
find /home/user/public_html/ -user nobody -exec chown user:user {} \;
find /home/user/public_html/ -perm 777 -exec chmod 755 {} \;
Run that for each user on the system, and you won’t have any phpsuexec internal server errors.
is really, really mean 😡