[Wine] Windows and Ubuntu and Windows and......

Martin Gregorie martin at gregorie.org
Sat Aug 27 15:24:41 CDT 2011


On Sat, 2011-08-27 at 14:32 -0500, jorl17 wrote:
>  locate is another utility similar to find but that uses indexing
> (someone correct me if that's wrong) to make it work faster
> 
'locate' is fast because it searches a database of all the filenames in
the system. The database is rebuilt on a daily basis when the cron
daemon runs 'updatedb' via the mlocate.cron script [1], so it can can be
up to 24 hours out of date. The command 'locate text' will list all the
files or directories that have 'text' anywhere in their absolute
pathname, i.e. if you wanted to find a file called recipes_etc and
entered the command 'locate etc', locate would list it if it existed
when updatedb was last run but would also list the several hundred files
in the /etc directory structure. 'locate' is very fast because all the
text it searches is gathered into one place but you have to be aware
that its never fully up to date, that it is matching on absolute path
names and that it always looks at every filename anywhere in your
system. 

'find', on the other hand, is a lot slower because it has to read
through all the directories its been asked to search but is always
up-to-date because it is looking directly at the filing system. It has
fewer gotchas because of this. It can also search just a selected part
of the filing system. e.g. if you are on your $HOME directory, running

	find . -name '*etc*'  

will only search the current directory ('.') and all the directories
within it. Specifying the search text as '*etc*' is necessary to find
files containing 'etc'. If you just asked for 'find . -name etc' it
would only find files and directories whose name is 'etc' and only
'etc'. If you put globs (* matches zero or more characters) or question
marks (? matches a single character in that position) in the search
pattern you should enclose them in single quotes to prevent the shell
from expanding them. 

Find is extremely versatile: it understands and can use file creation
time or last access time as search terms and can also run commands
against matching files:

	find . -name '*.bak' -exec rm {} \;

will delete all files with a .bak extension in the current directories
and those inside it. {} is replaced with the matching file name when the
command (rm) is run and ; ends the command to be run: it has to be
escaped as shown so it will be included as the end of the -exec command
rather that the shell taking it as the end of the 'find' command.

[1] cron normally runs the jobs in /etc/cron.daily around 3AM but, if
the computer isn't running then, it will remember that some jobs haven't
been run when its next started and will run them some time on the next
hour or two. 

Martin





More information about the wine-users mailing list