linux学习之locate指令,让你更快的查找文件

1.介绍

locate是一个Unix实用程序,用于快速查找文件和目录。它是find命令的一个更方便和高效的替代品,find命令搜索整个文件系统,而locate命令则查看系统中定期更新的文件数据库。因此,搜索完成得更快。

2.指令

locate -h            
Usage: plocate [OPTION]... PATTERN...

  -b, --basename         search only the file name portion of path names
  -c, --count            print number of matches instead of the matches
  -d, --database DBPATH  search for files in DBPATH
                         (default is /var/lib/plocate/plocate.db)
  -i, --ignore-case      search case-insensitively
  -l, --limit LIMIT      stop after LIMIT matches
  -0, --null             delimit matches by NUL instead of newline
  -N, --literal          do not quote filenames, even if printing to a tty
  -r, --regexp           interpret patterns as basic regexps (slow)
      --regex            interpret patterns as extended regexps (slow)
  -w, --wholename        search the entire path name (default; see -b)
      --help             print this help
      --version          print version information

3.常用指令

locate 1.txt

locate -i a.txt 忽略大小写

locate *.txt 查找以txt结尾的文件

locate -n 10 1.txt 查找1.txt文件,显示前10个

locate -r ‘1\.txt$’ 查找以1.txt结尾的文件,里面要转义 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值