There are tons of free and paid apps available for Mac to identify duplicate files and clean them, but do you know you can identify and delete duplicate files easily using the Mac Terminal, all you need is a package called fdupes
You can download this package using brew
brew install fdupes
GitHub: https://github.com/adrianlopezroche/fdupes
Example: Find all duplicates in the Downloads folder% fdupes -r -S Downloads
2513563 bytes each:
Downloads/mysql-connector-java-8.0.30/mysql-connector-java-8.0.30.jar
Downloads/mysql-connector-java-8.0.30.jar
1113 bytes each:
Downloads/2020101_Image.png
Downloads/temp.png
24958 bytes each:
Downloads/college-trip.mp4
Downloads/college-trip-copy.mp4
As you can see, I was able to get duplicate files - Images, Software, and Videos with the size they occupy!
Few useful options-r --recurse :for every directory given follow subdirectories encountered within
-s --symlinks :follow symlinks
-G --minsize=SIZE :consider only files greater than or equal to SIZE bytes
-L --maxsize=SIZE :consider only files less than or equal to SIZE bytes
-A --nohidden :exclude hidden files from consideration
-S --size :show size of duplicate files
Deleting the files
Use -d as an option with the command, Note: You should be extra cautious while using this command to delete file,
% fdupes -d -r /Downloads/myFiles
You will get an interactive screen for duplicate files asking which one to keep.
![Find and delete files using Mac Terminal Command Find and delete files using Mac Terminal Command](https://code2care.org/howto/find-duplicate-files-using-mac-terminal-command/images/Find and delete files using Mac Terminal Command.jpg)
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- Fix: grunt: command not found (Mac/Windows)
- AppleScript Example with TextEdit
- How to copy Password of Wifi on your Mac
- Install OpenJDK Java (8/11/17) versions using brew on Mac (Intel/M1/M2)
- How to check if a port is in use using terminal [Linux or macOS]
- Cut, Copy and Paste Keyboard Shortcuts on Mac Keyboard
- [macOS] NetBeans IDE cannot be installed. Java (JRE) found on your computer but JDK XX or newer is required.
- How to Remove Widgets from macOS Sonoma 14 Desktop
- Turn off Auto-Capitalization on macOS Ventura 13
- How to Go To /usr/local/bin on Mac Terminal?
- How to Open TextEdit on Mac
- Mac: How to Open Android Studio from Terminal
- How to change the default location of Mac Screenshot
- Display Seconds in Digital Clock on Mac Menu Bar [macOS]
- How to install homebrew (brew) on M1 Mac
- Must Know Homebrew Commands for Mac/Linux Users
- Steps to Uninstall Roblox on Mac (macOS)
- How to change the System Settings Sidebar icon size Mac Ventura 13
- How to set Out Of Office (OOO) on Outlook for Mac [Updated 2023]
- Trigger Notification Center Message using Mac Terminal Command
- [fix] macOS Ventura - Python3 xcrun: error: invalid active developer path missing xcrun at CommandLineTools
- How to Install Rust Language on Mac (macOS)
- How to minimize all Windows in Mac
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS]
- How to make TextEdit the default text Editor on Mac
- JSON with PHP Example: JSON Tutorial - Json-Tutorial
- How to check if Key Exists in Python Dictionary? - Python
- How to Split a String using Rust Language - Rust
- FileZilla Connection time out Failed to retrieve directory listing - FTP
- How to Set PowerShell as Default Shell on Windows Terminal - Windows
- Microsoft AI-900 Fundamental: A look at the Official Study Guide For Exam - Microsoft
- Get Current Local Date and Time using Java 8 DateTime API - Java
- Get the file location of git config values - Git