Delete .DS_Store recursively from all directories and sub-directories
📣 Sponsor
On a Mac, it is common to run into an issue when committing files to a git repo, where a file named .DS_Store
appears in every folder. This file, although it contains useful information for the directory, is usually not something you want to commit to your repo. Similar problems exist on linux as well.
Sometimes, despite adding this to your .gitignore
file, it still somehow ends up in your git repo. To remove all instances of a particular file, such as .DS_Store, on your computer, you can run the following command:
find . -name ".DS_Store" -delete
If you want to delete any other file, just replace ".DS_Store" with that file's name. The below, for example, will delete all files called "main.js".
find . -name "main.js" -delete
This will work on Linux and Mac.
More Tips and Tricks for Linux
- How to Remove Empty and Non Empty Directories in Linux
- How the ls command works on Linux
- How to count all files in a directory in Linux
- How the cd command works in Linux
- How the cp Command works on Linux
- How to make a Symbolic Link on Linux
- Find all files containing a string or text on Linux and Mac
- Speed up your Website by Converting your Images to WebP from Terminal
- How the chmod command works on Linux
- Delete .DS_Store recursively from all directories and sub-directories