Delete multiple files by wildcard in directories

Posted on 2007-10-12
Last Modified: 2010-08-05
Hello.  I am needing to delete a bunch of files that are hidden in directories and subdirectories. What command switches would I use with the rm command?

I do not want to actually delete the directories just certain files. Basically, all file with a *.DS_STORE.  The folder layout would be like this:


Question by:swhitlow
    LVL 48

    Accepted Solution

    find /directory -name "*.DS_STORE" -exec rm -f {} \;
    LVL 43

    Expert Comment

    The above is valid, but it's known to be really slow, and will remove matched dirs as well
    find /directory -type f -name '*.DS_STORE' | xargs rm -fv

    Author Comment

    Thanks Tintin! That worked!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now