• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2373
  • Last Modified:

Delete multiple files by wildcard in directories

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
swhitlow
Asked:
swhitlow
1 Solution
 
TintinCommented:
find /directory -name "*.DS_STORE" -exec rm -f {} \;
0
 
ravenplCommented:
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
 
swhitlowAuthor Commented:
Thanks Tintin! That worked!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now