?
Solved

Delete multiple files by wildcard in directories

Posted on 2007-10-12
3
Medium Priority
?
2,362 Views
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:

/directory/
     /subdir1/fileneedsdeleted.php
    /subdir1/fileneedstostay.php
    /subdir2/
           /subdir/fileneedsdeleted.php

Thanks!
0
Comment
Question by:swhitlow
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 20063629
find /directory -name "*.DS_STORE" -exec rm -f {} \;
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 20063676
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
0
 

Author Comment

by:swhitlow
ID: 20063694
Thanks Tintin! That worked!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month16 days, 23 hours left to enroll

864 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