Re: removing directories
> 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.
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
討論串 (同標題文章)
完整討論串 (本文為第 6 之 6 篇):