Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Search and compress filing of files

Shulou Source: shulou.com Published: 2022-06-03 05:42:48 11月24日 Update

Search and compress filing of files

Locate

Find

Compression and archiving

Locate

Main use

Query the pre-built file index database on the system

Locate-find files by namelocate [OPTION]... PATTERN...

When locate queries files, it searches / var/lib/mlocate/mlocage.db. The database is automatically updated periodically when the system is idle. The manual update command is updatedb. The construction of the index needs to traverse the entire root file system, which consumes more resources. However, locate has the following features:

1. Fuzzy search, fast 2. 5%. Non-real-time search, the search is the full path of the file, not the file name 3. It is possible to search only directories where the user has read and execute permissions

Common parameters

-d:-- database, specify the directory where the database is located

-I:-- ignore-case, ignore case when searching

-n N: enumerate only the first N matching items

-r:-- regexp, regular expressions are supported when searching

Use the example

Look for files that start with sh in the / etc/ directory:

[root@centos7 #] locate / etc/sh / etc/shadow/etc/shadow-/etc/shells [root@centos7 ~ #] locate-r "/ etc/\

Tags: File directory command size permissions user data backup path example condition content parameter time output file name search name real-time tool Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS Redmi MySQL Shulou Information