removing directories

Matthew Seaman m.seaman at
Fri Nov 4 18:09:02 UTC 2011

On 04/11/2011 17:41, Rodrigo Gonzalez wrote:
> El 04/11/11 13:25, Graeme Dargie escribió:
>> Ok this might be a bit of a newbie question but here goes.
>> I have a large number of directories  around 300 which all have sub
>> dirs, some of those have sub dirs in each of these there are two
>> further sub dirs called pages and thumbnails, is there an easy way to
>> remove all the pages and thumbnail dirs from the tree?
>> Regards
>> G
> I dont know how to make in one command....but to delete thumbnails
> directories
> find . -type d -name thumbnails -exec rm -rf {} \;
> You can do the same for the pages directories
> To test what you will delete please run
> find . -type d -name thumbnails -print
> and see that it is correct

In one command:

find . -depth 3 -type d \( -name pages -o -name thumbnails \) \
   -exec rm -rf '{}' +

The '-depth 3' bit avoids deleting any pages or thumbnails directories
higher up the tree, assuming that any such exist.  Leave it out if that
isn't a concern.

Use -print as Rodrigo suggests to avoid foot-shooting scenarios...



Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP:     Ramsgate
JID: matthew at               Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
Url :

More information about the freebsd-questions mailing list