How to find and delete directory recursively on Linux or Unix-like system

Posted on in Categories , , last updated June 22, 2017

I type ‘find . -type d -iname foo -delete‘ command to find the foo directories and delete them. However, I am getting an error message that read as find: cannot delete './hourly.4/data/foo': Directory not empty on Linux server. How do delete directories based on find command output on Linux or Unix-like system?