Image for post
Image for post

Find and remove specific files via the command line.

For example, on a Mac, you’ll often find files. To find and remove these you can run the following command to search for and remove every instance:

$ find . -type f -name ".DS_Store" -exec rm {} ;

This will find all files () called and execute the (remove) command on that set .

Run from the top directory and it will recurse its way into all sub directories and remove the files. This can be a dangerous command so use with caution.

You can also adapt the command to execute something else (e.g. a to another location for example.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store