b_ r t k n_ r

thoughts & experiences.

Find and delete files and folders in OSX terminal

Finding and deleting files and folders in OSX is simple. Open your terminal. In order to just find your files/folders (non destructive):

For files:

find . -name "Icon?" -type f

For folders:

find . -name "Icon?" -type d

For files and folders

find . -name "Icon?" -type f -o -name "Icon?" -type d

In order to delete them, just add -delete operator to the end (DESTRUCTIVE):

For files:

find . -name "Icon?" -type f -delete

For folders (although you may get a warning message saying ‘No such file or directory’):

find . -name "Icon?" -type d -exec rm -rf {} \;

The ? symbol after the filename is a wildcard for a single character. To enable more characters, use * instead.