Find and remove specific files via the command line.

For example, on a Mac, you’ll often find .DS_Store 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 (-type f) called .DS_Store and execute the rm (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 mv to another location for example.




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Inheritance in Java

Continuous Release Pipeline with Travis-CI

State Management, Breaking Bad Habits, & More…

What is the Optimal Team Timetrial Strategy?

How to revert to a previous commit and push to the remote repository.

Github logo

Serverless — Host a website using S3, CloudFront and CloudFlare

Using TopoR to Autoroute a KiCad PCB

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
Praj Basnet

Praj Basnet

More from Medium

Introduction to Unix Command Line

How to make custom command in linux

Linux Directories