views:

475

answers:

5

I recently moved my whole local web development area over to using MacPorts stuff, rather than using MAMP on my Mac. I've been getting into Python/Django and didn't really need MAMP any more.

Thing is, I have uninstalled MAMP from the Applications folder, with the preferences file too, but how come when I run the 'locate MAMP' command in the Terminal it still shows all my /Applications/MAMP/ stuff as if it's all still there? And when I 'cd' into /Applications/MAMP/ it doesn't exist?

Something to do with locate being a kind of index searching system, hence things these old filepaths are cached? Please explain why, and how to sort it so they don't show anymore.

+2  A: 

You've got the right idea: locate uses a database called 'locatedb'. It's normally updated by system cron jobs (not sure which on OS X); you can force an update with the updatedb command. See http://linux-sxs.org/utilities/updatedb.html among others.

Val
For the same reason, locate fails to show you recently-created files - any files created since the last updatedb aren't seen by locate.
Carl Manaster
A: 

Indeed the locate command searches through an index, that's why it's pretty fast. The index is generated by the updatedb command, which is usually run as a nightly or weekly job.

So to update it manually, just run updatedb.

Lars Haugseth
A: 

According to the man page, its database is updated once a week:

NAME
     locate.updatedb -- update locate database

SYNOPSIS
     /usr/libexec/locate.updatedb

DESCRIPTION
     The locate.updatedb utility updates the database used by locate(1).  It is typically run once a week by
     the /etc/periodic/weekly/310.locate script.
Jim Puls
A: 

Take a look at the locate man page

http://unixhelp.ed.ac.uk/CGI/man-cgi?locate+1

You'll see that locate searches a database, not your actual filesystem. You can update that database by using the updatedb command.

Also, since it's a database, unless you do update it regularly, locate wouln't find files that are in your filesystem that arn't in the database.

James Caccese
+1  A: 

The other answers are correct about needing to update the locate database. I've got this alias to update my locate DB:

alias update_locate='sudo /usr/libexec/locate.updatedb'

I actually don't use locate all that much anymore now that I've found mdfind. It uses the spotlight file index which OSX is much better at keeping up to date compared to the locatedb. It also has quite a bit more power in what it can search from the command line.

Ted Naleid