Five find commands for Linux Find,locate,whereis,which,type

Source: Internet
Author: User

Five find commands for Linux 1. Find the most common and powerful command that can look up any file. Format $ find   Specify directory   Specify condition   Specify action   Specify directory: the directory to be searched and its subdirectories, the default current directory. Specify criteria: The characteristics of the file you are searching for. Specify actions: Specific processing of the search results.   Reminder: If none of the parameters are given, find defaults to the current directory and its subdirectories, and returns all results to the computer's screen.   For example: $ find.  -name ' qq* '  -ls finds all files with ' QQ ' in the current directory and its subdirectories, and displays detailed information   such as find.  -type   F  -mmin  -10  Search The current directory, the normal files that have been updated in the last 10 minutes. If you do not add  -type parameter   Retrieve normal file + special file + directory  ----------------------------------------------------------------- 2. Locate locate is actually another way of writing "Find  -name", but it's much faster than find. Because Locat does not retrieve a specific directory, it simply retrieves a database (/var/lib/locatedb), which contains all the local file information. The database is updated daily, and you need to manually force the refresh if you change. That is, locate cannot retrieve content that was updated recently (within a day). If you are detecting content that is updated today, you need to first use the   "updatedb" command   For example, locate  /etc/sh to retrieve all files that begin with SH in the ETC directory;  $ Locate  -I    ~/QQ retrieves all files beginning with QQ in the user's home directory, ignoring case  ------------------------------------------------------------------- -----------3. Whereis can only be used for retrieval of   program names, and can only retrieve binary files (parameter-B), man description file (parameter-m), and source code (parameter-s). &nBSP; Returns the information if the argument is omitted.   For example $ whereis  grep  ------------------------------------------------------------------------ ---------------------------------------4.   which function: In the path specified by the path variable, search for the location of a system command and return the first search result. That is, using the which   command, you can see whether a command exists, and which command is executed in which location. For example $ which grep -------------------------------------------------------------------------------------------- ---5. The Type type command is not really a find command. It is used to differentiate whether a command is brought by the shell or is provided by a standalone binary file outside the shell. If a command is an external command, then using the-p parameter, the path to the command is displayed, which is equivalent to which. For example $ type cd system prompt, CD is the Shell's own command   $type  GREP system hint, grep is a shell external command, so give a path  $ type-p grep equals which command lookup & Nbsp;from http://www.ruanyifeng.com/blog/2009/10/5_ways_to_search_for_files_using_the_terminal.html  Reference http ://www.linuxhaxor.net/5-ways-to-search-for-files-using-the-terminal-in-linux/ 

Five find commands for Linux find,locate,whereis,which,type

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.