Command to remove all files and folders recursively including, hidden ones, on MAC OS Terminal?

rm -rf * will remove all files and folders but not hidden ones.

rm -rf .* will remove all hidden files and folders, but not those that are not hidden, correct?

What command should one type, in order to delete all files and folders including the hidden ones? (except . and ..); ?


Solution 1:

rm -rf * .*

will do the trick.

Solution 2:

Try this:

find . -mindepth 1 -delete

I'm not certain that -mindepth is supported by all implementations of find; if yours doesn't have it, -path should give another way to keep it from trying to delete .:

find . -path "*/*" -delete