Linux命令-locate命令

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.
-------------------------------------------------------------------------------------
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值