Chris Green chris@areti.co.uk writes:
I tend always to use find when looking for files but recently discovered 'locate'.
However the 'locate' way of doing things strikes me a not very useful as it searches for the string you give it in every part of the filename which, in general, gives far too many hits.
E.g. if I do "locate organ" in the hope of finding some file containing organ music I get thousands of hits with 'Korganizer' etc. in. I also tried "locate -r '^organ" but that found nothing (which is also wrong).
"find / -name 'organ*'" does what I want (if slowly), is there any way of doing the same search with locate?
This is in the man page:
If a pattern is a plain string -- it contains no metacharacters -- locate displays all file names in the database that contain that string anywhere. If a pattern does contain metacharacters, locate only dis- plays file names that match the pattern exactly.
It sounds like you want: locate '*/organ'