From owner-freebsd-questions@FreeBSD.ORG Wed Jan 27 19:25:41 2010 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 6A86C1065679 for ; Wed, 27 Jan 2010 19:25:41 +0000 (UTC) (envelope-from aryeh.friedman@gmail.com) Received: from mail-qy0-f203.google.com (mail-qy0-f203.google.com [209.85.221.203]) by mx1.freebsd.org (Postfix) with ESMTP id 1DCC18FC25 for ; Wed, 27 Jan 2010 19:25:40 +0000 (UTC) Received: by qyk41 with SMTP id 41so4170112qyk.29 for ; Wed, 27 Jan 2010 11:25:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=ACEfGUhluawGhFqqUjaCkn10JlaTDFDmj8NqDC91ZLY=; b=Snrel5gstlSGH2wwfN8pXsgJx5jSTq5lE7x5Xc22lRUBjlHsHEujaG44pzUGwl9u/h tMW7FRM2Axf4BawPSe1Iwl0F8I40SwWYf5n1ZPcO6ZgeOv/N74Av8KqjdkgSnFtB1mfj mtqYxVwiCxj/3RiLcbcsMg0hJAARnxI2Kp9Vo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=rrncn/+C0OUEg1w9+zYKkAR31n/xP2Dxye1U8hp4EmSvbqavpLFWnVgoWKyLa4epiu ONcoTd6Q9YYm7CMXrZQg6my23QF4hUUrBVdRIale6SxfWf5XnDaZAp6zPMYt+C+/mq4s HO4xew16hSDAxY+psd/e/dhUU4fOSFaNziSpg= Received: by 10.224.79.200 with SMTP id q8mr3046094qak.341.1264620340265; Wed, 27 Jan 2010 11:25:40 -0800 (PST) Received: from aryeh-desktop.istudentunion.com (ool-44c0cd7a.dyn.optonline.net [68.192.205.122]) by mx.google.com with ESMTPS id 21sm123471qyk.0.2010.01.27.11.25.38 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 27 Jan 2010 11:25:38 -0800 (PST) Message-ID: <4B609335.8060808@gmail.com> Date: Wed, 27 Jan 2010 14:25:41 -0500 From: "Aryeh M. Friedman" User-Agent: Thunderbird 2.0.0.23 (X11/20100120) MIME-Version: 1.0 To: Glen Barber References: <4B6090FC.4070002@gmail.com> <20100127191737.GA70795@orion.hsd1.pa.comcast.net> In-Reply-To: <20100127191737.GA70795@orion.hsd1.pa.comcast.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: OT: finding every file not in a list 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: Wed, 27 Jan 2010 19:25:41 -0000 Glen Barber wrote: > Hi, > > Aryeh M. Friedman wrote: > >> I have a list of files that should be in a dir tree and want to remove >> any files from the tree not in list (i.e. if it is on the list keep it >> else rm it)... any quick way to do this? >> > > Perhaps something like this will help: > > find /dir -type f | \ > grep -v `cat excludelist` | \ > xargs rm > > Regards, > > Note quite since it will see every file after the first as a file to be grepped instead of filtered out... I was playing with the idea of doing a tcsh foreach loop on each file and then using it cut down the output of find... the problem there is it is O(n^2) where is a "good" solution is O(n) [I need to do this {don't ask the reasons} everytime I build a program I am developing]