From owner-freebsd-questions@freebsd.org Sat Feb 15 13:42:08 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A460D23B814 for ; Sat, 15 Feb 2020 13:42:08 +0000 (UTC) (envelope-from 4250.10.freebsd-questions=freebsd.org@email-od.com) Received: from s1-b0c6.socketlabs.email-od.com (s1-b0c6.socketlabs.email-od.com [142.0.176.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48KWdC3ySNz4GR0 for ; Sat, 15 Feb 2020 13:42:07 +0000 (UTC) (envelope-from 4250.10.freebsd-questions=freebsd.org@email-od.com) DKIM-Signature: v=1; a=rsa-sha256; d=email-od.com;i=@email-od.com;s=dkim; c=relaxed/relaxed; q=dns/txt; t=1581774128; x=1584366128; h=content-transfer-encoding:content-type:mime-version:references:in-reply-to:message-id:subject:to:from:date:x-thread-info; bh=QTYOMTP+5C86uWXsdWVVeaEPxTwy8O4dd0pCULFVEzM=; b=vGFEuHpluwi0khLM3XoGzWaplXykNV/uATfKYMpl6xGpY2q0legfycKyQSM5PEf7WTmMg4QPkelRL7K3Gr7amm9AJEFlL/9TOIiRyVFr1/2mdiGuXChUQ4kKId6Gmz2rPk2dR+yuxAnvw3FYzuVpllewU2QWDgGNjl7P+1t+Zjk= X-Thread-Info: NDI1MC4xMi43NDAwMDAwMDQ5ZjAwOC5mcmVlYnNkLXF1ZXN0aW9ucz1mcmVlYnNkLm9yZw== Received: from r2.h.in.socketlabs.com (r2.h.in.socketlabs.com [142.0.180.12]) by mxsg2.email-od.com with ESMTP(version=Tls12 cipher=Aes256 bits=256); Sat, 15 Feb 2020 08:41:57 -0500 Received: from smtp.lan.sohara.org (EMTPY [185.202.17.215]) by r2.h.in.socketlabs.com with ESMTP(version=Tls12 cipher=Aes256 bits=256); Sat, 15 Feb 2020 08:41:56 -0500 Received: from [192.168.63.1] (helo=steve.lan.sohara.org) by smtp.lan.sohara.org with smtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1j2xhj-000FiO-CJ for freebsd-questions@freebsd.org; Sat, 15 Feb 2020 13:41:55 +0000 Date: Sat, 15 Feb 2020 13:41:55 +0000 From: Steve O'Hara-Smith To: freebsd-questions@freebsd.org Subject: Re: Removal script Message-Id: <20200215134155.6f8e6f901c9175dbdbef7808@sohara.org> In-Reply-To: <24af365c-bfab-b5ac-72e3-675b0450b75f@cloudzeeland.nl> References: <24af365c-bfab-b5ac-72e3-675b0450b75f@cloudzeeland.nl> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; amd64-portbld-freebsd12.0) X-Clacks-Overhead: "GNU Terry Pratchett" Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 48KWdC3ySNz4GR0 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=pass header.d=email-od.com header.s=dkim header.b=vGFEuHpl; dmarc=none; spf=pass (mx1.freebsd.org: domain of 4250.10.freebsd-questions=freebsd.org@email-od.com designates 142.0.176.198 as permitted sender) smtp.mailfrom=4250.10.freebsd-questions=freebsd.org@email-od.com X-Spamd-Result: default: False [-1.89 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.99)[-0.991,0]; R_DKIM_ALLOW(-0.20)[email-od.com:s=dkim]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:142.0.176.0/20]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[sohara.org]; FORGED_SENDER_VERP_SRS(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCVD_COUNT_THREE(0.00)[4]; IP_SCORE(0.10)[ip: (-0.27), ipnet: 142.0.176.0/22(0.55), asn: 7381(0.27), country: US(-0.05)]; MV_CASE(0.50)[]; DKIM_TRACE(0.00)[email-od.com:+]; RCVD_IN_DNSWL_NONE(0.00)[198.176.0.142.list.dnswl.org : 127.0.15.0]; ENVFROM_VERP(0.00)[]; FORGED_SENDER(0.00)[steve@sohara.org,4250.10.freebsd-questions=freebsd.org@email-od.com]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:7381, ipnet:142.0.176.0/22, country:US]; FROM_NEQ_ENVFROM(0.00)[steve@sohara.org,4250.10.freebsd-questions=freebsd.org@email-od.com]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Feb 2020 13:42:08 -0000 On Sat, 15 Feb 2020 14:31:59 +0100 Jos Chrispijn wrote: > I am looking for a way to remove a nested subdirectory in a directory. > > Example: > directory /mysources has a certain number of subdirectories which > contain subdirectory 'nonsense' in various subdirectories, which contain > also subdirectory 'nonsense', etc. > > What I would like to do is that the script removes all 'nonsense' > folders in the base /mysources. > Can you pls tell me how I can do that savest? Thanks! If the nonesense directories are not empty and you want them gone complete with contents then: find /mysources -name nonesense -type d -depth -exec rm -rf {} \; If they're empty then: find /mysources -name nonesense -type d -delete -- Steve O'Hara-Smith