Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Emulating 'locate'

DervishD <raul@xxxxxxxxxxxx> writes:

>     Hi Bart :)
>  * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
>> [We should just go off and have our own little mailing list.]
>     Well... As I said a few weeks ago, I'm on the way of learning Zsh
> and sometimes I practice what is said in the manual doing things like
> these. Sometimes I have success, others I don't. I know, I make many
> questions, and maybe you are the only able to answer then, so don't
> feel guilty if you want to ignore most of them ;)))
> [ ... ]
>>     locate() { print -l /**/*${^*}*{,/**/*} }
>     Ok, it works like a charm... Thanks a lot, as always :)

I might have missed something about this in the first part of the thread
a couple weeks ago (those messages have already expired on my system),
but in case it wasn't mentioned before, I want to point out that this
function is _extremely_ slow in comparison to the standard 'locate'
command.  It traverses through every accessible item on every accessible
file system in order to check for a match.  On my server, it's literally
thousands of times slower than using the standard 'locate'.

I'm not sure how it compares to this:

  locate() { find / -name "*${^*}*" -print }

... but it's certainly has more or less the same order of magnitude
of slowness.

Figuring this out is a very good learning experience for zsh.  However,
I would not recommend installing this function for everyday use on a
reasonably sized system.

> [ ... ]

 Lloyd Zusman

Messages sorted by: Reverse Date, Date, Thread, Author