bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suggestion for updatedb


From: James Youngman
Subject: Re: Suggestion for updatedb
Date: Fri, 11 May 2007 09:28:45 +0100

On 5/9/07, Diamond, Brett - AES <address@hidden> wrote:
I suggest adding the "-u" parameter on the sort that feeds frcode.  That way duplicate 
entries that may have been introduced by specifying overlapping directories with 
"--localpaths" will be pruned.  The justification is that, although the find command may 
have found the item more than once, but the item itself only exists once.

Basically, replace:

} | $sort -f | $frcode $frcode_options > $LOCATE_DB.n

with

} | $sort -fu | $frcode $frcode_options > $LOCATE_DB.n

I actually make this change whenever I install findutils, and thought I should 
pass it back.

This change makes a great deal of sense.  Unfortunately, there are a
number of difficulties with the idea.  None of them are insuperable
perhaps, but here they are:

1. Using sort -fu will eliminate from locate's output any filenames
which differ only in case.   So if you have a Readme file and a README
file, only one of these would appear in locate databases made with the
above command line.  This is easily addressed:-

} | $sort -u | $sort -f | $frcode $frcode_options > $LOCATE_DB.n

2. We still cannot guarantee that duplicates will not be generated,
since locate may search more than one database via the -d option or
LOCATE_PATH.   If one filename exists in two databases, locate will
currently print it.

3. It's useful not to have to guarantee that the output of locate is
already sorted, because this allows optimisations and database
representation changes that might otherwise be difficult.

However, I take your point.   One would normally assume that on a
system that only has one locate database it would be possible (though
often inadvisable) to do this

locate -0 some-pattern | xargs -0 rm

While, as you point out, changing the default way the locate database
is built might oblige you to do this instead:

locate -0 some-pattern | sort -zu | xargs -0 rm
(this uses "sort -zu" since there is no "uniq -z")

James.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]