linux-File Search Command

Source: Internet
Author: User

1. File Search Command Locate

Locate command format

Locate file name

Search by file name in the background database, search faster

/var/lib/mlocate (depending on the Linux version, the database name is different)

Locate command to search the background database, updated every day database updatedb, only search to (new key files when searched, need updatedb to search in real time)

UpdateDB

Update Database

Linux does not have a locate command to install Yum install mlocate,updatedb before it can be used

/etc/updatedb.conf: Viewing search filter rules

2. Command Search command Whereis and which

Search System Command

-B: Query only executable files

-W: View only where the Help document is located

Which: It also contains aliases, but does not see the corresponding Help document

PATH environment variable: Defines the paths to the System Search command: Echo $PATH

3. File Search command Find

Search for files: find "search scope" "Search criteria"

Avoiding large-scale searches can be very costly to system resources

Find is to search the system for eligible file names. If a match is required, use wildcards to match

Find/-name Install.log

Find/root-iname (case-insensitive search) Install.log

Find/root-user|-nouser Root: Search by Owner

Find/var/log-mtime + 10: Find files modified for 10 days

-10 10 days to modify the file

10 10 days of modified files on the same day

+10 files modified 10 days ago

Atime File access time

CTime changing file properties

Mtime Modifying file contents

Find. -size 25k|-25k|+25k: Find files in the current directory equal to | less than | Larger than |25k size

Find. Inum 26624 Find I node for 26624 file

Find. -size +20k-a-size-50k-exec (processing the result command of the previous search) Ls-lh {}\;

-a:and Logic and

-o:or logic or

{} \; standard format

4. String Search command grep, find&&grep difference

grep [Options] string file name

-I: Ignore case

-V: excludes the specified string

Differences: Inclusion relationships for search results

Find: Searches the system for eligible file names and, if necessary, matches the wildcard characters exactly.

grep: Searches for qualifying strings in a file, matches with regular expressions if required, regular expressions contain matches

linux-File Search Command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.