From owner-freebsd-questions Tue Jul 9 01:05:10 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id BAA13735 for questions-outgoing; Tue, 9 Jul 1996 01:05:10 -0700 (PDT) Received: from diablo.ppp.de (diablo.ppp.de [193.141.101.34]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id BAA13345 for ; Tue, 9 Jul 1996 01:02:24 -0700 (PDT) Received: from allegro.lemis.de by diablo.ppp.de with smtp (Smail3.1.28.1 #1) id m0udXkG-000QgiC; Tue, 9 Jul 96 10:02 MET DST From: grog@lemis.de (Greg Lehey) Organisation: LEMIS, Schellnhausen 2, 36325 Feldatal, Germany Phone: +49-6637-919123 Fax: +49-6637-919122 Received: (grog@localhost) by allegro.lemis.de (8.6.9/8.6.9) id JAA09789; Tue, 9 Jul 1996 09:47:36 +0200 Message-Id: <199607090747.JAA09789@allegro.lemis.de> Subject: Re: Deleting a tree To: compland@ism.com.br (Helio Coelho Jr. - CompuLand Informatica) Date: Tue, 9 Jul 1996 09:47:36 +0200 (MET DST) Cc: questions@FreeBSD.org (FreeBSD Questions) In-Reply-To: <199607081959.QAA28587@unix1.ism.com.br> from "Helio Coelho Jr. - CompuLand Informatica" at Jul 8, 96 04:59:24 pm X-Mailer: ELM [version 2.4 PL23] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-questions@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk Helio Coelho Jr. - CompuLand Informatica writes: > > Hi Greg: > > Sorry about the confusion. My question is: sometimes you want to > remove an application you installed. For example: /usr/local/sendmail. > I want to remove the sub-directory sendmail and all it's contents, without > going into sendmail, deleting the files and after going into all of the > subdirectories of sendmail, deleting all the files. I checked rmdir man > page and seems to me that you only can remove an EMPTY directory. If there is > a single file inside this directory, you have to go there, delete the file > first, step out, and then you can remove the directory. But it sometimes > is tedious. If the directory has 10 sub-directories inside it, you have to > remove one by one, by hand! I though of a script, that can recurse into the > directory you selected and remove the files inside it, and after remove the > directory itself. OK. You don't need a script. I gave you the answer for that: # rm -rf /usr/local/sendmail The -r option says "recursively descend into subdirectories and delete them". The -f option says "don't ask questions". > I know that, if you remove the directory only, the files will be there, > in the disk. I wonder if there's a script that can, recursively remove > all the contents of the directory you selected and any sub-directory it > might have, and after that remove the directory itself. (Like Deltree,in DOS). > >> >> Whichever it is, you haven't made your request clear. Do you make a >> distinction between archives and files? > > Yes. Sorry, this time I didn't make myself clear. *How* do you distinguish between archives and files? In UNIX, an archive is just a special kind of file. In this example, I still don't understand. Are you referring to the archives you used for installation, outside the trees you're deleting? Of course they won't be deleted. Greg