马丁博客


linux locate 快速查找命令介绍

2011-11-01 10:20, lamp, by , 27 views.

时间过得好快,一转眼一年又快到过年了,很久没有和大家分享了,工作实在太忙了。
使用linux的人都会知道find查找命令。
下面有关于find的使用说明 :linux 查找命令大全。
下面给大家介绍一个快速查找工具locate,支持正则。
一般linux系统都会默认安装。没有默认安装也不要着急。

ubuntu:sudo apt-get install locate;
centos:yum -y install mlocate;

工作原理:通过定时任务定时生成文件名相关的数据文件(一般会存放在【/var/lib/mlocate/mlocate.db】),当然定时任务不会很实时,这个会导致刚刚安装的软件找不到,这时候大家需要使用(updatedb)来更新locate数据文件。
使用方法:locate xx(要查找的文件名) -l num(要显示的行数)。当然这个文件名在系统中出现太多,就需要用到-l这个参数。不然等着刷屏吧。
正则使用参数:-r, –regexp REGEXP
Search for a basic regexp REGEXP. No PATTERNs are allowed ifthis option is used, but this option can be specified multipletimes.
更多使用方法:man locate;
http://linux.about.com/od/commands/l/blcmdl1_locate.htm



发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>