Common Linux commands-file search commands (below)

Source: Internet
Author: User

Locate files and directories

Format: locate file and directory

We can see that we searched for test5 and output the result to us. We created a new file named newfile1. However, we did not find it when using locate. We may find that we use locate to search very quickly, because a directory database is maintained for us in Linux, the search is performed in the database that has been stored, rather than in the real-time read/write hard disk search. So the speed is very fast, but the database is not always updated, it is a set-time update. We didn't write the data just inserted, so we couldn't find it. We can use the following command.

 

Updatedb updates or creates a database for the entire system directory file.

Format: updatedb

This command is usually used with the previous command order.

 

Grep is used to search for words or phrases in the specified mode in the file and display all rows that contain the given string mode on the standard output.

Format: grep [Option] Find mode file name

-E interprets the search mode as an extended regular expression.

-F: The search mode is interpreted as a simple character.

-B displays the position of the row containing matching characters in the file before each row of the output, which is expressed by byte offset.

-I is case insensitive.

-R recursively searches for files in all subdirectories

-N: add the row number before the output contains rows in the matching mode.

Specifically, this is not a file search command.

From: Meng xiangyue's column

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.