The Find command under Linux

Source: Internet
Author: User

Under Linux often with the Find command, my own most commonly used is find Whereis locate

About Find

I use the basic functions of find, such as

Find /-name filename

Search for files in a directory.

The find command supports regular and can be written as

find . -name abc*

But the find lookup is very slow, and find finds more content that can be combined with the grep command.

The function of find is very powerful, as follows:

Find is the most common and powerful look-up command you can use to find any file you're looking for. Find uses the following format: $ find < Specify directory > < specify conditions > < specify action >-< Specify directory;: the directory to be searched and all its subdirectories.  The current directory is assumed by default.  -< specified conditions;: The characteristics of the file to be searched. -< specify actions;: Specific processing of search results. If no parameters are added, find searches the current directory and its subdirectories by default, and does not filter any results (that is, all files are returned) and displays them all on the screen. Example of use of find: $ find.  -name ' my* ' searches the current directory (with subdirectories, below), all files with the file name beginning with my. $ find.  -name ' my* '-ls searches the current directory for all files with the file name beginning with my, and displays their details. $ find. -type f-mmin- searches the current directory for all the normal files that have been updated in the last 10 minutes. If you do not add the-type f parameter, search for normal files + special files + directories. 

About Whereis

Whereis is used to search for programs and cannot search for anything else.

Whereis FTP

About the use of Whereis

The Whereis command can only be used for program name searches, and only binary files (parameter-B), man description file (parameter-m), and source code file (parameter-s) are searched. If the argument is omitted, all information is returned. Example of use of the Whereis command: $ whereis grep

About Locate

Locate is a faster find.

Locate filename

As above, the usage is super simple.

But locate has a problem, if a file is new, then you use locate most likely to find this file.

The locate command is actually another way of writing "Find-name", but much faster than the latter because it does not search for a specific directory, but instead searches for a database (/var/lib/locatedb), which contains all the local file information. The Linux system automatically creates this database and updates it automatically once a day, so you can't find the latest changed files using the Locate command.

Some uses of locate

Locate /etc/shLocate ~/Locate -i ~/m Search user home directory, all files beginning with M, And the case is ignored. 

Reference:

One Linux command per day: Locate command

Five Find commands for Linux

The Find command under Linux

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.