Linux search command set

Source: Internet
Author: User
Linux search command set I believe that friends familiar with Linux systems know the search command & mdash; find in Linux. In fact, there are other search commands in Linux, but it is not so often used by people. The following describes several search commands in Linux including the find command and their differences .... Linux search command set I believe that friends familiar with Linux systems know the search command-find in Linux. In fact, there are other search commands in Linux, but they are not so often used, the following describes several search commands in Linux including the find command and their differences. Www.2cto.com 1. findfind is the most common and powerful search command. you can use it to find any file you want. The format of find is as follows: $ find <指定目录> <指定条件> <指定动作> - <指定目录> : The directory to be searched and all its subdirectories. The current directory is used by default. - <指定条件> : The features of the file to be searched. - <指定动作> : Specific processing of search results. If no parameters are added, find searches for the current directory and its subdirectories by default, does not filter any results (that is, returns all files), and displays them all on the screen. Example of using find: $ find.-name 'My * 'searches for all files whose names start with my in the current directory (including subdirectories, the same as below. $ Find.-name 'My * '-ls searches the current directory for all files whose names start with my and displays their details. $ Find.-type f-mmin-10 search for all common files updated in the current directory in the past 10 minutes. If the-type f parameter is not added, search for common files + special files + directories. 2. the locatelocate command is actually another method of "find-name", but it is much faster than the latter because it does not search for a specific directory, instead, search for a database (/var/lib/locatedb) that contains information about all local files. The Linux system automatically creates the database and updates the database once a day. Therefore, the latest changed files cannot be found using the locate command. To avoid this problem, you can use the updatedb command to manually update the database before using locate. Use instance of the locate command: $ locate/etc/sh to search for all files starting with sh in The etc directory. $ Locate ~ /M searches all files starting with m in the user's home directory. $ Locate-I ~ /M searches all files starting with m in the user's home directory, and ignores the case. 3. the whereiswhereis command can only be used for searching program names. it can only search binary files (parameter-B), man description files (parameter-m), and source code files (parameter-s ). If the parameter is omitted, all information is returned. Example of how to use the whereis command: $ whereis grep4. whichwhich command searches for the location of a system command in the PATH specified by the PATH variable and returns the first search result. That is to say, by using the which command, you can see whether a system command exists and where the command is executed. The instance for using the which command: $ which grep5. typetype is actually not a search command. it is used to distinguish whether a command is provided by shell, it is also provided by an independent binary file outside the shell. If a command is an external command, use the-p parameter to display the path of the command, which is equivalent to the which command. Example of using the type command: $ type cd system will prompt that cd is a built-in shell command (build-in ). $ Type grep system prompts that grep is an external command and displays the path of this command. After $ type-p grep is added with the-p parameter, it is equivalent to the which 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.