{"id":11752,"date":"2019-03-16T04:38:31","date_gmt":"2019-03-16T04:38:31","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11752"},"modified":"2019-03-16T04:38:31","modified_gmt":"2019-03-16T04:38:31","slug":"5-command-line-tools-to-find-files-quickly-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/16\/5-command-line-tools-to-find-files-quickly-in-linux\/","title":{"rendered":"5 Command Line Tools to Find Files Quickly in Linux"},"content":{"rendered":"<p>Searching or finding files on a Linux system from the terminal can be a little of a challenge especially for newbies. However, there are several command line tools\/utilities for locating files in Linux.<\/p>\n<p>In this article, we will review 5 command line tools to find, locate and search files quickly on Linux systems.<\/p>\n<h3><strong>1. Find Command<\/strong><\/h3>\n<p><a href=\"https:\/\/www.tecmint.com\/35-practical-examples-of-linux-find-command\/\" target=\"_blank\" rel=\"noopener\">find command<\/a>\u00a0is a powerful, widely used CLI tool for searching and locating files whose names match simple patterns, in a directory hierarchy. Using find is simple, all you need to do is provide a starting point (top of the directory heirarchy) where the search beings. This can be the current directory or any other directory where you suspect the file you are looking for is stored.<\/p>\n<p>After the starting point, you can specify an expression (composed of test, actions, options and operators) which describes how to match files and what to do with the files that were matched.<\/p>\n<p>It supports multiple options to locate files using attributes such as permissions, users, groups, file type, date, size and other possible criteria. You can learn some useful find command usage examples in the following articles:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/35-practical-examples-of-linux-find-command\/\" target=\"_blank\" rel=\"noopener\">35 Practical Examples of Linux Find Command<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/find-directory-in-linux\/\" target=\"_blank\" rel=\"noopener\">Ways to Use \u2018find\u2019 Command to Search Directories More Efficiently<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/how-to-find-files-with-suid-and-sgid-permissions-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Find Files With SUID and SGID Permissions in Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/linux-find-command-to-search-multiple-filenames-extensions\/\" target=\"_blank\" rel=\"noopener\">How to Use \u2018find\u2019 Command to Search for Multiple Filenames (Extensions) in Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/find-and-sort-files-modification-date-and-time-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Find and Sort Files Based on Modification Date and Time in Linux<\/a><\/li>\n<\/ol>\n<h3><strong>2. Locate Command<\/strong><\/h3>\n<p><a href=\"https:\/\/www.tecmint.com\/linux-locate-command-practical-examples\/\" target=\"_blank\" rel=\"noopener\">locate command<\/a>\u00a0is another commonly used CLI utility for searching files quickly by name, just like find command. However, it is practically more efficient and faster compared to its counterpart because, instead of searching through the file system when a user initiates a file search operation (the way find works), locate queries a database which contains bits and parts of files and their corresponding paths on the file system.<\/p>\n<p>This database can be prepared and updated using the\u00a0<strong>updatedb<\/strong>\u00a0command. Note that\u00a0<strong>locate<\/strong>\u00a0will not report files created after the most recent update of the relevant database.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/install-locate-command-to-find-files-in-centos\/\" target=\"_blank\" rel=\"noopener\">How to Install \u2018locate Command\u2019 to Find Files in Linux<\/a><\/p>\n<h3><strong>3. Grep Command<\/strong><\/h3>\n<p>Although\u00a0<a href=\"https:\/\/www.tecmint.com\/12-practical-examples-of-linux-grep-command\/\" target=\"_blank\" rel=\"noopener\">grep command<\/a>\u00a0is not a tool for directly searching files (its instead used to print lines matching a pattern from one or more files), you can employ it to locate files. Assuming you know a phrase in the file(s) you are looking for or you are looking for a file that contains a particular string of characters,\u00a0<strong>grep<\/strong>\u00a0can help you list all files that contain a particular phrase.<\/p>\n<p>For example, if you are looking for a\u00a0<strong>README.md<\/strong>\u00a0file which contains the phrase \u201c<strong>An assortment<\/strong>\u201d, which you suspect should be somewhere in your home directory, possibly in\u00a0<strong>~\/bin<\/strong>, you can locate it as shown.<\/p>\n<pre>$ grep -Ri ~\/bin -e \"An assortment\" \r\nOR\r\n$ grep -Ri ~\/bin\/ -e \"An assortment\" | cut -d: -f1\r\n<\/pre>\n<p>Where the grep flag:<\/p>\n<ul>\n<li><code>-R<\/code>\u00a0\u2013 means search the specified directory recursively<\/li>\n<li><code>-i<\/code>\u00a0\u2013 means ignore case distinctions<\/li>\n<li><code>-e<\/code>\u00a0\u2013 specifies the phrase to be used as a pattern for searching<\/li>\n<li><code>-d<\/code>\u00a0\u2013 specifies the delimter<\/li>\n<li><code>-f<\/code>\u00a0\u2013 sets the field to be printed<\/li>\n<\/ul>\n<p>You can learn some useful grep command usage examples in the following articles:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/12-practical-examples-of-linux-grep-command\/\" target=\"_blank\" rel=\"noopener\">12 Practical Examples of Linux Grep Command<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/linux-grep-commands-character-classes-bracket-expressions\/\" target=\"_blank\" rel=\"noopener\">11 Advance Linux Grep Commands Usage and Examples<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/find-a-specific-string-or-word-in-files-and-directories\/\" target=\"_blank\" rel=\"noopener\">How to Find a Specific String or Word in Files and Directories<\/a><\/li>\n<\/ol>\n<h3><strong>4. Which Command<\/strong><\/h3>\n<p><strong>which command<\/strong>\u00a0is a tiny and straightforward utility for locating the binary of a command; it outputs the absolute path of a command. For example:<\/p>\n<pre>$ which find\r\n$ which locate\r\n$ which which\r\n<\/pre>\n<h3><strong>5. Whereis Command<\/strong><\/h3>\n<p><strong>whereis command<\/strong>\u00a0is also used to locate a command and it additionally shows the absolute path of the source, and manual page files for the command.<\/p>\n<pre>$ whereis find\r\n$ whereis locate\r\n$ whereis which\r\n$ whereis whereis\r\n<\/pre>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/find-linux-command-description-and-location\/\" target=\"_blank\" rel=\"noopener\">5 Ways to Find a \u2018Binary Command\u2019 Description and Location on File System<\/a><\/p>\n<p>That\u2019s all for now! If we have missed any Commandline tools\/utilities for quickly locating files on a Linux system, let us know via the comment form below. You can ask any questions concerning this topic as well.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/find-files-quickly-in-linux-terminal\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Searching or finding files on a Linux system from the terminal can be a little of a challenge especially for newbies. However, there are several command line tools\/utilities for locating files in Linux. In this article, we will review 5 command line tools to find, locate and search files quickly on Linux systems. 1. Find &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/16\/5-command-line-tools-to-find-files-quickly-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;5 Command Line Tools to Find Files Quickly in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11752","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11752","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11752"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11752\/revisions"}],"predecessor-version":[{"id":11754,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11752\/revisions\/11754"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}