From owner-freebsd-questions@FreeBSD.ORG Fri Nov 4 20:08:07 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E0CB106566C for ; Fri, 4 Nov 2011 20:08:07 +0000 (UTC) (envelope-from bonomi@mail.r-bonomi.com) Received: from mail.r-bonomi.com (mx-out.r-bonomi.com [204.87.227.120]) by mx1.freebsd.org (Postfix) with ESMTP id 3B6128FC0A for ; Fri, 4 Nov 2011 20:08:06 +0000 (UTC) Received: (from bonomi@localhost) by mail.r-bonomi.com (8.14.4/rdb1) id pA4K7Qk5028125; Fri, 4 Nov 2011 15:07:26 -0500 (CDT) Date: Fri, 4 Nov 2011 15:07:26 -0500 (CDT) From: Robert Bonomi Message-Id: <201111042007.pA4K7Qk5028125@mail.r-bonomi.com> To: arab@tangerine-army.co.uk, freebsd-questions@freebsd.org In-Reply-To: <0EE458C34045A44DBC2CA2DC5CEB42B5239647FE05@mercury.universe.galaxy.lcl> Cc: Subject: Re: removing directories X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2011 20:08:07 -0000 > From owner-freebsd-questions@freebsd.org Fri Nov 4 12:30:00 2011 > From: Graeme Dargie > To: "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.