rm on steroids (a safer way)
I came across an excellent tip about mixing rm and find commands in Linux shell.
The only thing I’d add to it is a bit of safety. Before executing the mix of find and rm, run the find command with the same options, but without rm. It will pri…
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