Ever try to delete the contents of a large directory in nix type operating system? If you have many files you will get an error like “list to long” or something like that. This happens to some of my directories I use to cache pages, sometimes I want to clear them out manually.

So now what?
The easiest and quickest solution is to remove the entire directory with a command like this.
(Now, before you do it, you need to realize that you will have to recreate the directory when it’s done, so take note of the permissions you have on the directory first.)
rm -rf directoryname

You can see the directory is now gone “No such file or directory”.
Yes, that is exactly what I wanted!
Thanks.
Saved a couple of hours.
In case you want remove just htm files…
find . -type f -name “*.htm” -exec rm {} \;
This isn’t a very effective solution:
find . -type f -name “*.htm” -exec rm {} \;For a directory with 20000 files, 20000 times shell will execute rm and this will use a lot of CPU and IO time.
A much more efficient solution for directories with many files is:
find . -type f -name “*.htm” | xargs -l500 rm -fThis will execute rm for every 500 files, causing much less hassle for the system.
In general, i think using xargs is a whole lot better than -exec in find, and you’d best avoid it when possible.
It may also be used in combination with grep, to clean a folder out of files containing a specific string a-la:
grep -rF 'some string in files' . | xargs -l500 rm