Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Nov 2011 15:07:26 -0500 (CDT)
From:      Robert Bonomi <bonomi@mail.r-bonomi.com>
To:        arab@tangerine-army.co.uk, freebsd-questions@freebsd.org
Subject:   Re: removing directories
Message-ID:  <201111042007.pA4K7Qk5028125@mail.r-bonomi.com>
In-Reply-To: <0EE458C34045A44DBC2CA2DC5CEB42B5239647FE05@mercury.universe.galaxy.lcl>

next in thread | previous in thread | raw e-mail | index | archive | help
> From owner-freebsd-questions@freebsd.org  Fri Nov  4 12:30:00 2011
> From: Graeme Dargie <arab@tangerine-army.co.uk>
> To: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
> Date: Fri, 4 Nov 2011 16:25:26 +0000
> Subject: removing directories
>
> 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, so
> me of those have sub dirs in each of these there are two further sub dirs ca
> lled pages and thumbnails, is there an easy way to remove all the pages and 
> thumbnail dirs from the tree?


Note: _please_ hit the enter key at around column 72, not all mail clients do
smart word-wrap, when confronted with long lines.

There are a number of ways to approach this problem.  

*IF* the 'pages' and 'thumbnails' directories are a 'fixed' number of levels
down from the directory containing those 'around  300' directories, you can
use simple wildcards -- e.g. something like 'rm -fr */*/*/pages'.

A more general approach is to use find(1), something like:
    find . -type d ( -name pages -or -name thumbnails ) -delete
or (if the above complains about 'non-empty' directories
    find . -type d ( -name pages -or -name thumbnails ) -exec rm -fr {} \;

BEWARE: the parens may need to be quoted, to prevent the shell from giving 
them special meaning.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201111042007.pA4K7Qk5028125>