[ALUG] 'locate' isn't always helpful, how to do better?

(Ted Harding) ted.harding at nessie.mcc.ac.uk
Thu Feb 22 11:22:22 GMT 2007


On 22-Feb-07 Eur Ing Chris Green wrote:
> While the 'locate' command is very useful at times, especially if you
> have lost a specific file it's much less useful when looking for, for
> example, a directory which has a rather common name.
> 
> E.g. I was just trying to find where I have bits of vmware installed,
> doing a 'locate vmware' just produces zillions of lines of output. I
> don't (in this case) want to know all the files which are located
> somewhere below a 'vmware' directory, I just want to know the location
> of the directory.
> 
> I know I can use an RE in locate but it's not all *that* simple to
> come up with an RE to do it.
> 
> I could also use 'find' which would get me exactly the result I want
> with a fairly straightforward command, but it would take ages.
> 
> What I really want is a 'find' that uses the locate database, I'm
> surprised no one has written one - or have they?
> 
> -- 
> Chris Green

The following doesn't quite do what you're looking for, since it also
throws up files named "vmware" as well as directories. However, the
result is compact, and is produced quite quickly. You could pipe the
output through a filter which tests for "directory".


> locate vmware | grep 'vmware$' | sort -u
/etc/init.d/rc3.d/K22vmware
/etc/init.d/rc3.d/S01vmware
/etc/init.d/vmware
/etc/vmware
/home/ted/.vmware
/home/ted/vmware
/usr/X11R6/lib/X11/sax/profile/vmware
/usr/bin/vmware
/usr/lib/vmware
/usr/share/doc/packages/ethereal/README.vmware
/usr/share/doc/susehilf/raw_pacs/en/vmware
/usr/share/doc/vmware
/var/lock/subsys/vmware



HTH
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 22-Feb-07                                       Time: 11:21:57
------------------------------ XFMail ------------------------------



More information about the main mailing list