locate:
locate 让使用者可以很快速的搜寻档案系统内是否有指定的档案。其方法是先建立一个包括系统内所有档案名称及路径的数据库,之后当寻找时就只需查询这个数据库,而不必实际深入档案系统之中了。在一般的 distribution 之中,数据库的建立都被放在 crontab 中自动执行。
----------------------------------------------------------------------------
查找和test01相关的所有文件:
# locate test01
/home/dx/test01
/home/dx/test01/a.txt
/home/dx/test01/b.txt
/home/dx/test01/c.txt
/home/dx/test01/d.txt
/home/dx/test01/e.txt
/home/dx/test01/f.txt
/home/dx/test01/g.txt
/home/dx/test01/h.txt
/home/dx/test01/tail.txt
-------------------------------------------------------------------------------
搜索home目录下所有以li开头的文件:
# locate /home/li
/home/lizhen
/home/lizhen/.Dog.swp
/home/lizhen/.swp
/home/lizhen/Dog.java
-------------------------------------------------------------------------------
至多显示5个输出:
# locate -n 5 test01
/home/dx/test01
/home/dx/test01/a.txt
/home/dx/test01/b.txt
/home/dx/test01/c.txt
/home/dx/test01/d.txt
-------------------------------------------------------------------------------
显示程式的版本讯息:(大写的'V')
# locate -V
mlocate 0.26
Copyright (C) 2007 Red Hat, Inc. 保留所有权利。
本软件在 GPL v.2 下发布。
本程序不提供任何担保,在法律允许的范围内予以排除。
------------------------------------------------------------------------------
显示辅助讯息:
# locate -h
Usage: locate [OPTION]... [PATTERN]...
Search for entries in a mlocate database.
-A, --all only print entries that match all patterns
-b, --basename match only the base name of path names
-c, --count only print number of found entries
-d, --database DBPATH use DBPATH instead of default database (which is
/var/lib/mlocate/mlocate.db)
-e, --existing only print entries for currently existing files
-L, --follow follow trailing symbolic links when checking file
existence (default)
-h, --help print this help
-i, --ignore-case ignore case distinctions when matching patterns
-l, --limit, -n LIMIT limit output (or counting) to LIMIT entries
-m, --mmap ignored, for backward compatibility
-P, --nofollow, -H don't follow trailing symbolic links when checking file
existence
-0, --null separate entries with NUL on output
-S, --statistics don't search for entries, print statistics about each
used database
-q, --quiet report no error messages about reading databases
-r, --regexp REGEXP search for basic regexp REGEXP instead of patterns
--regex patterns are extended regexps
-s, --stdio ignored, for backward compatibility
-V, --version print version information
-w, --wholename match whole path name (default)
将 bug 报告给 mitr@redhat.com.
-------------------------------------------------------------------------------------