Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

What am I misunderstanding about "locate"?

0 views
Skip to first unread message

laredotornado

unread,
Nov 13, 2009, 3:14:04 PM11/13/09
to
Hi,

I'm using Mac 10.5.6. When I fire up my terminal, navigate to a
certain directory, and then execute this command

ocho:webapp dalvarado$ locate myco-galc-capitol-tours-webapp.war
ocho:webapp dalvarado$

I get no results back. But if I run ...

ocho:webapp dalvarado$ find . -name "*.war"
./target/myco-galc-capitol-tours-webapp-1.0-SNAPSHOT.war
./target/myco-galc-capitol-tours-webapp.war

You can see that the file I was searching for comes back as the second
result. So why didn't locate tell me where it was? Or should I be
using a different command?

- Dave

Steve W. Jackson

unread,
Nov 13, 2009, 3:31:03 PM11/13/09
to
In article
<aae5d674-857c-43de...@w19g2000yqk.googlegroups.com>,
laredotornado <laredo...@zipmail.com> wrote:

The locate command takes a "pattern" to match, which implies that it
uses regular expression pattern matching when searching the database(s)
for your search query. I've been familiar with, but far from expert at,
regular expressions for years, so I can't say with certainty what's
wrong. But I'm guessing that the special characters (those dashes) are
causing some grief. Had you tried typing "locate capitol" you should've
gotten back a list of every file and folder from the default locate
database with that string in its name.
--
Steve W. Jackson
Montgomery, Alabama

laredotornado

unread,
Nov 13, 2009, 4:02:14 PM11/13/09
to
On Nov 13, 1:31 pm, "Steve W. Jackson" <stevewjack...@knology.net>
wrote:
> In article
> <aae5d674-857c-43de-9d54-ef64267e4...@w19g2000yqk.googlegroups.com>,


I just tried "locate capitol" but that returned no results, even
though I confirmed there are files matching that pattern (using the
find command). - Dave

nospam

unread,
Nov 13, 2009, 4:29:53 PM11/13/09
to
In article
<fb04699e-ecbb-4761...@o10g2000yqa.googlegroups.com>,
laredotornado <laredo...@zipmail.com> wrote:

> I just tried "locate capitol" but that returned no results, even
> though I confirmed there are files matching that pattern (using the
> find command). - Dave

is the locate database up to date?

Doug Anderson

unread,
Nov 13, 2009, 4:32:25 PM11/13/09
to
laredotornado <laredo...@zipmail.com> writes:

The man page can be helpful, though I don't know if it addresses your
issues. There are two issues mentioned in the man page:

1) locate doesn't search the file system. It searches a database
(updated periodically, but what the period is can vary from system
to system). So the database can be expected to be somewhat out of
date at any given time.

2) When the database is created, it is run by user "nobody" which
means it will skip directories not readable by that user, at
least.

Ronald Bruck

unread,
Nov 16, 2009, 12:38:04 PM11/16/09
to
In article <stevewjackson-DD6...@news.individual.net>,

Assuming, of course, that he runs "updatedb" as root occasionally, or
has a cron script to do it for him...

-- Ron Bruck

laredotornado

unread,
Nov 16, 2009, 12:41:58 PM11/16/09
to
On Nov 16, 10:38 am, Ronald Bruck <br...@math.usc.edu> wrote:
> In article <stevewjackson-DD6675.14310313112...@news.individual.net>,

That leads me to my next question ... where is the locate db update
controlled? Do I need to set up a cron or is this set up in System
Preferences or somewhere similar? - Dave

Jim Gibson

unread,
Nov 16, 2009, 2:26:58 PM11/16/09
to
In article
<89345af4-f1b6-4f5c...@k17g2000yqh.googlegroups.com>,
laredotornado <laredo...@zipmail.com> wrote:

See 'man locate' and 'locate -S' for more info. The locate database is
in /var/db/locate.database. The command to schedule regular updates is:

sudo launchctl load -w
/System/Library/LaunchDaemons/com.apple.locate.plist

(according to 'locate -S')

--
Jim Gibson

Fred Moore

unread,
Nov 16, 2009, 2:29:14 PM11/16/09
to

> > Assuming, of course, that he runs "updatedb" as root occasionally, or
> > has a cron script to do it for him...
> >

> That leads me to my next question ... where is the locate db update
> controlled? Do I need to set up a cron or is this set up in System
> Preferences or somewhere similar? - Dave

In 10.5: .private/var/db/locate.database
(I found this with EasyFind ;) )

As I understand it, the weekly maintenance script updates
locate.database.

OR there is a handy little GUI front end for locate called Locator which
will do it on command.

Paul Sture

unread,
Nov 17, 2009, 10:06:18 AM11/17/09
to
In article <161120091126589778%jimsg...@gmail.com>,
Jim Gibson <jimsg...@gmail.com> wrote:

I don't see that file on 10.5.8 (I'll have a more thorough dig later).

An easy way to rebuild the locate database (e.g. after adding a large
number of files) is

sudo periodic weekly

This will of course do other weekly stuff such as rotating your logs as
well.

--
Paul Sture

zit

unread,
Nov 22, 2009, 9:53:25 AM11/22/09
to
>On Nov 17, 11:06 pm, Paul Sture <paul.nos...@sture.ch> wrote:

>      sudo periodic weekly

Under Leopard, it was fairly easy to get updatedb to run as root.
It is very useful to have a quick search of all files and directories
on one's own machine.
I tried and failed to do this under Snow Leopard ( OS X10.6).

Anyone have the recipe?

0 new messages