Thursday, December 29, 2005

Making unix find more like Mac OS Find
On the command line, my favorite utility to find files is the locate command. Locate gives lightning fast results because it caches file names in a database (which is usually updated by cron).

Locate works fine for me, except when I'm looking for a file I just installed. So I have to fall back to the find command.

The find command, however, is not like the Mac OS find command. It defaults to files named literally what you specify (while the Mac OS find command works on partial file names).

So, the find syntax to find file names when partial names are specified:
find /location/to/search/in/ -name "*filename*" -print

Notes:

  • You most put double quotes around the *filenane* part (else the shell will get to those characters before find does)
  • You most specify -print at the end (or you won't see your results)