Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jan 2010 14:25:41 -0500
From:      "Aryeh M. Friedman" <aryeh.friedman@gmail.com>
To:        Glen Barber <glen.j.barber@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: OT: finding every file not in a list
Message-ID:  <4B609335.8060808@gmail.com>
In-Reply-To: <20100127191737.GA70795@orion.hsd1.pa.comcast.net>
References:  <4B6090FC.4070002@gmail.com> <20100127191737.GA70795@orion.hsd1.pa.comcast.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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]



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4B609335.8060808>