locate,find

locate:基于事先构建好的索引库查找,速度比较快,但是不是实时的。有时候可能出现索引不到的情况

-b :只匹配路径中的基名
-c :统计出符合条件的数量
  • 安装locate
[root@host test]# yum provides locate
已加载插件:fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
mlocate-0.26-8.el7.x86_64 : An utility for finding files by name   #包名称

...
[root@host test]# yum install mlocate #安装这个就好了
  • locate 
[root@host test]# locate man1
/usr/local/apache/man/man1
/usr/local/apache/man/man1/ab.1
/usr/local/apache/man/man1/apxs.1
/usr/local/apache/man/man1/dbmmanage.1
/usr/local/apache/man/man1/htdbm.1
/usr/local/apache/man/man1/htdigest.1
......
  • locate -b :只匹配基名

 

[root@host test]# locate -b man1
/usr/local/apache/man/man1
/usr/local/pcre/share/man/man1
/usr/local/share/man/man1
/usr/local/share/man/man1x
/usr/share/man/man1
...
/usr/share/man/pl/man1
/usr/share/man/pt_BR/man1
/usr/share/man/ru/man1
/usr/share/man/sv/man1
/usr/share/man/tr/man1
/usr/share/man/zh_CN/man1
/usr/share/man/zh_TW/man1
  • locate -c:统计符合条件的数量
[root@host test]# locate -c man1
1086
[root@host test]# locate -b -c man1
24

注:如果是本次开机之后创建的文件,locate是否能找到

[root@host test]# touch 777999
[root@host test]# locate -c 777999     #此处显示是找不到的
0

注:系统周期性更新索引库。此时如果想要locate 查找,就需要手动更新索引库了

[root@host test]# updatedb
[root@host test]# locate -c 777999
1
[root@host test]# locate 777999
/root/test/777999

find:实时查找工具,速度较locate慢一些

注:find前面写过详细的,直接连接查看就可以了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值