찾기 명령은 무엇입니까?

coldplay.xixi
풀어 주다: 2020-11-02 14:46:14
원래의
18723명이 탐색했습니다.

찾아보기 명령은 파일이나 디렉터리를 찾는 데 사용됩니다. 찾기 명령은 특정 디렉터리를 검색하지 않고 데이터베이스를 검색하기 때문에 [find -name]보다 훨씬 빠릅니다. 무늬]...].

찾기 명령은 무엇입니까?

locate 명령:

1. 명령 소개

Locate(locate) 명령은 파일이나 디렉터리를 찾는 데 사용됩니다. Locate 명령은 특정 디렉터리가 아닌 /var/lib/mlocate/mlocate.db 데이터베이스를 검색하기 때문에 find -name보다 훨씬 빠릅니다. 이 데이터베이스에는 모든 로컬 파일에 대한 정보가 포함되어 있습니다. 리눅스 시스템에서는 이 데이터베이스를 자동으로 생성하고 하루에 한 번씩 자동으로 업데이트하기 때문에, whereis와 located를 사용하여 파일을 검색하면 삭제된 데이터가 발견되거나, 방금 생성된 파일을 찾을 수 없는 경우가 있습니다. 이유는 데이터베이스 파일이 업데이트되지 않았기 때문입니다. 이러한 상황을 방지하려면 업데이트된 명령을 사용하여 찾기를 사용하기 전에 데이터베이스를 수동으로 업데이트할 수 있습니다. 전체 찾기 작업은 실제로 네 부분으로 구성됩니다:

  • /usr/bin/updatedb 주로 데이터베이스를 업데이트하는 데 사용되며 crontab을 통해 자동으로 완료됨

  • /usr/bin/locate 파일 위치 쿼리

  • / etc/updatedb.conf updateb

  • /var/lib/mlocate/mlocate.db 구성 파일 파일 정보를 저장하는 파일

2, Usage

locate [OPTION]... [PATTERN]...
로그인 후 복사

3, Options

  -b, --basename         match only the base name of path names
  -c, --count            只输出找到的数量
  -d, --database DBPATH  使用DBPATH指定的数据库,而不是默认数据库 /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             显示帮助
  -i, --ignore-case      忽略大小写
  -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 eachused database
  -q, --quiet            安静模式,不会显示任何错误讯息
  -r, --regexp REGEXP    使用基本正则表达式
      --regex            使用扩展正则表达式
  -s, --stdio            ignored, for backward compatibility
  -V, --version          显示版本信息
  -w, --wholename        match whole path name (default)
로그인 후 복사

4 , 예시

예제 1: etc 디렉터리에서 my로 시작하는 모든 파일을 검색하세요

[root@cent6 lib]# locate /etc/my
/etc/my.cnf
로그인 후 복사

예제 2: 새로 추가된 파일을 찾을 수 없습니다. updateb를 사용하세요

[root@cent6 ~]# touch new.txt
[root@cent6 ~]# locate new.txt
[root@cent6 ~]# updatedb
[root@cent6 ~]# locate new.txt
/root/new.txt
로그인 후 복사

예제 3: updateb의 구성 파일 /etc/updatedb. conf

[root@cent6 ~]# cat /etc/updatedb.conf 
PRUNE_BIND_MOUNTS = "yes"
PRUNEFS = "9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset debugfs devpts ecryptfs exofs fuse fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs sockfs sysfs tmpfs ubifs udf usbfs"
PRUNENAMES = ".git .hg .svn"
PRUNEPATHS = "/afs /media /net /sfs /tmp /udev /var/cache/ccache /var/spool/cups /var/spool/squid /var/tmp"
로그인 후 복사

관련 학습 권장 사항: linux 비디오 튜토리얼

위 내용은 찾기 명령은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!