Results 1 to 5 of 5
HI everyone. Can please someone tell me which is the fastest way to search for specific file on local disk. I tried to use find file utility in konqueror, but ...
- 09-01-2007 #1Linux Newbie
- Join Date
- Feb 2006
- Location
- Slovenia
- Posts
- 162
How to search for files on disk?
HI everyone. Can please someone tell me which is the fastest way to search for specific file on local disk. I tried to use find file utility in konqueror, but it takes days to find the specified file. Is there a command that would allow faster file searching. I use suse 10.2. Thanx for help.
- 09-01-2007 #2Just Joined!
- Join Date
- Aug 2007
- Posts
- 17
locate works pretty well..
Have you tried beagle?
You have to be sure locate is installed:
rpm -qa | grep locate
kio-locate-0.4.5-29
findutils-locate-4.2.28-24 <- Needs to be installed for the command locate
Man Locate gives you:
LOCATE(1)
NAME
locate - list files in databases that match a pattern
SYNOPSIS
locate [-d path | --database=path] [-e | -E | --[non-]existing] [-i |
--ignore-case] [-0 | --null] [-c | --count] [-w | --wholename] |-b |
--basename] [-l N | --limit=N] [-S | --statistics] [-r | --regex ] [-P
| -H | --nofollow] [-L | --follow] [--version] [-A | --all] [-p |
--print] [--help] pattern...
DESCRIPTION
This manual page documents the GNU version of locate. For each given
pattern, locate searches one or more databases of file names and dis‐
plays the file names that contain the pattern. Patterns can contain
shell-style metacharacters: `*', `?', and `[]'. The metacharacters do
not treat `/' or `.' specially. Therefore, a pattern `foo*bar' can
match a file name that contains `foo3/bar', and a pattern `*duck*' can
match a file name that contains `lake/.ducky'. Patterns that contain
metacharacters should be quoted to protect them from expansion by the
shell.
If a pattern is a plain string — it contains no metacharacters — locate
displays all file names in the database that contain that string any‐
where. If a pattern does contain metacharacters, locate only displays
file names that match the pattern exactly. As a result, patterns that
contain metacharacters should usually begin with a `*', and will most
often end with one as well. The exceptions are patterns that are
intended to explicitly match the beginning or end of a file name.
The file name databases contain lists of files that were on the system
when the databases were last updated. The system administrator can
choose the file name of the default database, the frequency with which
the databases are updated, and the directories for which they contain
entries; see updatedb(1).
If locate's output is going to a terminal, unusual characters in the
output are escaped in the same way as for the -print action of the find
command. If the output is not going to a terminal, file names are
printed exactly as-is.
OPTIONS
-A, --all
Print only names which match all non-option arguments, not those
matching one or more non-option arguments.
-c, --count
Instead of printing the matched filenames, just print the total
number of matches we found, unless --print (-p) is also present.
-d path, --database=path
Instead of searching the default file name database, search the
file name databases in path, which is a colon-separated list of
database file names. You can also use the environment variable
LOCATE_PATH to set the list of database files to search. The
option overrides the environment variable if both are used.
Empty elements in the path are taken to be synonyms for the file
name of the default database. A database can be supplied on
stdin, using `-' as an element of path. If more than one element
of path is `-', later instances are ignored (and a warning mes‐
sage is printed).
The file name database format changed starting with GNU find and
locate version 4.0 to allow machines with different byte order‐
ings to share the databases. This version of locate can auto‐
matically recognize and read databases produced for older ver‐
sions of GNU locate or Unix versions of locate or find. Support
for the old locate database format will be discontinued in a
future release.
-e, --existing
Only print out such names that currently exist (instead of such
names that existed when the database was created). Note that
this may slow down the program a lot, if there are many matches
in the database. If you are using this option within a program,
please note that it is possible for the file to be deleted after
locate has checked that it exists, but before you use it.
-E, --non-existing
Only print out such names that currently do not exist (instead
of such names that existed when the database was created). Note
that this may slow down the program a lot, if there are many
matches in the database.
-L, --follow
If testing for the existence of files (with the -e or -E
options), consider broken symbolic links to be non-existing.
This is the default.
-P, -H, --nofollow
If testing for the existence of files (with the -e or -E
options), treat broken symbolic links as if they were existing
files. The -H form of this option is provided purely for simi‐
larity with find; the use of -P is recommended over -H.
-i, --ignore-case
Ignore case distinctions in both the pattern and the file names.
-l N, --limit=N
Limit the number of matches to N. If a limit is set via this
option, the number of results printed for the -c option will
never be larger than this number.
-m, --mmap
Accepted but does nothing, for compatibility with BSD locate.
-0, --null
Use ASCII NUL as a separator, instead of newline.
-p, --print
Print search results when they normally would not, because of
the presence of --statistics (-S) or --count (-c).
-w, --wholename
Match against the whole name of the file as listed in the
database. This is the default.
-b, --basename
Results are considered to match if the pattern specified matches
the final component of the name of a file as listed in the
database. This final component is usually referred to as the
`base name'.
-r, --regex
The pattern specified on the command line is understood to be a
regular expression, as opposed to a glob pattern. The Regular
expressions work in the same was as in emacs and find, except
for the fact that "." will match a newline. Filenames whose
full paths match the specified regular expression are printed
(or, in the case of the -c option, counted). If you wish to
anchor your regular expression at the ends of the full path
name, then as is usual with regular expressions, you should use
the characters ^ and $ to signify this.
-s, --stdio
Accepted but does nothing, for compatibility with BSD locate.
-S, --statistics
Print various statistics about each locate database and then
exit without performing a search, unless non-option arguments
are given. For compatibility with BSD, -S is accepted as a syn‐
onym for --statistics. However, the ouptut of locate -S is dif‐
ferent for the GNU and BSD implementations of locate.
--help Print a summary of the options to locate and exit.
--version
Print the version number of locate and exit.
ENVIRONMENT
LOCATE_PATH
Colon-separated list of databases to search. If the value has a
leading or trailing colon, or has two colons in a row, you may
get results that vary between different versions of locate.
SEE ALSO
find(1), locatedb(5), updatedb(1), xargs(1), glob(3), Finding Files
(on-line in Info, or printed)
BUGS
The locate database correctly handles filenames containing newlines,
but only if the system's sort command has a working -z option. If you
suspect that locate may need to return filenames containing newlines,
consider using its --null option.
The best way to report a bug is to use the form at http://savan‐
nah.gnu.org/bugs/?group=findutils. The reason for this is that you
will then be able to track progress in fixing the problem. Other com‐
ments about locate(1) and about the findutils package in general can be
sent to the bug-findutils mailing list. To join the list, send email
to bug-findutils-request@gnu.org.
LOCATE(1)
-------------------------------------------------------------------------
To update the locate DB use:
updatedb
man updatedb gives you:
UPDATEDB(1) UPDATEDB(1)
NAME
updatedb - update a file name database
SYNOPSIS
updatedb [options]
DESCRIPTION
This manual page documents the GNU version of updatedb, which updates
file name databases used by GNU locate. The file name databases con‐
tain lists of files that were in particular directory trees when the
databases were last updated. The file name of the default database is
determined when locate and updatedb are configured and installed. The
frequency with which the databases are updated and the directories for
which they contain entries depend on how often updatedb is run, and
with which arguments.
In networked environments, it often makes sense to build a database at
the root of each filesystem, containing the entries for that filesys‐
tem. updatedb is then run for each filesystem on the fileserver where
that filesystem is on a local disk, to prevent thrashing the network.
Users can select which databases locate searches using an environment
variable or command line option; see locate(1). Databases can not be
concatenated together.
The file name database format changed starting with GNU find and locate
version 4.0 to allow machines with different byte orderings to share
the databases. The new GNU locate can read both the old and new
database formats. However, old versions of locate and find produce
incorrect results if given a new-format database.
OPTIONS
--findoptions='-option1 -option2...'
Global options to pass on to find. The environment variable
FINDOPTIONS also sets this value. Default is none.
--localpaths='path1 path2...'
Non-network directories to put in the database. Default is /.
--netpaths='path1 path2...'
Network (NFS, AFS, RFS, etc.) directories to put in the
database. The environment variable NETPATHS also sets this
value. Default is none.
--prunepaths='path1 path2...'
Directories to not put in the database, which would otherwise
be. Remove any trailing slashes from the path names, otherwise
updatedb won´t recognise the paths you want to omit (because it
uses them as regular expression patterns). The environment
variable PRUNEPATHS also sets this value. Default is /tmp
/usr/tmp /var/tmp /afs.
--prunefs='path...'
File systems to not put in the database, which would otherwise
be. Note that files are pruned when a file system is reached;
Any file system mounted under an undesired file system will be
ignored. The environment variable PRUNEFS also sets this value.
Default is nfs NFS proc.
--output=dbfile
The database file to build. Default is /var/lib/locatedb.
--localuser=user
The user to search non-network directories as, using su(1).
Default is to search the non-network directories as the current
user. You can also use the environment variable LOCALUSER to
set this user.
--netuser=user
The user to search network directories as, using su(1). Default
is nobody. You can also use the environment variable NETUSER to
set this user.
--old-format
Create the database in the old format instead of the new one.
--version
Print the version number of updatedb and exit.
--help Print a summary of the options to updatedb and exit.
SEE ALSO
find(1), locate(1), locatedb(5), xargs(1) Finding Files (on-line in
Info, or printed)
BUGS
The updatedb program correctly handles filenames containing newlines,
but only if the system's sort command has a working -z option. If you
suspect that locate may need to return filenames containing newlines,
consider using its --null option.
The best way to report a bug is to use the form at http://savan‐
nah.gnu.org/bugs/?group=findutils. The reason for this is that you
will then be able to track progress in fixing the problem. Other com‐
ments about updatedb(1) and about the findutils package in general can
be sent to the bug-findutils mailing list. To join the list, send
email to bug-findutils-request@gnu.org.
UPDATEDB(1)
- 09-02-2007 #3Just Joined!
- Join Date
- Aug 2007
- Posts
- 3
- 09-02-2007 #4Linux Newbie
- Join Date
- Feb 2006
- Location
- Slovenia
- Posts
- 162
Thanx again guys.
- 09-02-2007 #5Linux Engineer
- Join Date
- Nov 2004
- Location
- Ft. Polk, LA
- Posts
- 796
If locate has been installed and updatedb has been run recently, just try 'locate filename' and unless it's in a weird place that updatedb is set not to look at, it will come up in seconds. Though this isn't always accurate, when updatedb is run it created a database of every file it finds, so when locate is run it looks through the db much quicker than if it looked through the fs. So if updatedb hasn't been run lately, it might not find the file or might find it in the wrong place.


Reply With Quote
