{"id":842,"date":"2020-10-23T13:54:01","date_gmt":"2020-10-23T13:54:01","guid":{"rendered":"https:\/\/linuxways.net\/?p=842"},"modified":"2023-11-25T01:55:56","modified_gmt":"2023-11-25T01:55:56","slug":"3-ways-for-finding-files-and-directories-in-linux","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/3-ways-for-finding-files-and-directories-in-linux\/","title":{"rendered":"3 ways to find files and directories in Linux"},"content":{"rendered":"<p>This article will go through how you can find files and directories in Linux. We will be using the locate, find, and grep command. Each command is discussed in detail below.<\/p>\n<p>We have used <strong>Ubuntu 20.04 LTS <\/strong>to demonstrate the process.<\/p>\n<h2>Using Locate command to find files and directories in Linux<\/h2>\n<p>The locate command offers faster results as it reads through the mlocate.db database which has all the file paths in your system.<\/p>\n<h3>Install locate<\/h3>\n<p>If you get the message below, you need to install locate.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"104\" class=\"wp-image-843\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-448.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-448.png 525w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-448-300x59.png 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/p>\n<p>The command for installing locate is:<\/p>\n<pre>sudo apt-get install mlocate<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"506\" height=\"39\" class=\"wp-image-844\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-449.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-449.png 506w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-449-300x23.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-449-501x39.png 501w\" sizes=\"auto, (max-width: 506px) 100vw, 506px\" \/><\/p>\n<p>The first step is entering your password. Once you enter your password, the installation starts.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"724\" height=\"488\" class=\"wp-image-845\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-450.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-450.png 724w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-450-300x202.png 300w\" sizes=\"auto, (max-width: 724px) 100vw, 724px\" \/><\/p>\n<p>You need to update the search database after the installation. Since locate relies on this database, you need to update it regularly to ensure efficiency. You need superuser privileges to update the mlocate database.<\/p>\n<pre>sudo updatedb<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"412\" height=\"31\" class=\"wp-image-846\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-451.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-451.png 412w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-451-300x23.png 300w\" sizes=\"auto, (max-width: 412px) 100vw, 412px\" \/><\/p>\n<h3>Searching for files using the filename<\/h3>\n<p>To look for files using their names, use the following command:<\/p>\n<pre>locate {filename}<\/pre>\n<p>We\u2019ll be looking for a file called, \u201ctextfile.txt\u201d, so the command will be:<\/p>\n<pre>locate textfile.txt<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"442\" height=\"30\" class=\"wp-image-847\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-452.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-452.png 442w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-452-300x20.png 300w\" sizes=\"auto, (max-width: 442px) 100vw, 442px\" \/><\/p>\n<p>The result will be the path to where your file is located.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"262\" height=\"27\" class=\"wp-image-848\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-453.png\" \/><\/p>\n<h3>Ignoring case sensitivity<\/h3>\n<p>By default, locate processes queries in a case-sensitive manner, meaning textfile.txt and TEXTFILE.TXT will point to different search results.<\/p>\n<p>As you can see, TEXTFILE.TXT could not be located.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"456\" height=\"37\" class=\"wp-image-849\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-454.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-454.png 456w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-454-300x24.png 300w\" sizes=\"auto, (max-width: 456px) 100vw, 456px\" \/><\/p>\n<p>You can ignore case sensitivity, by using the <strong>\u2013i<\/strong> option. The command is:<\/p>\n<pre>locate \u2013i {file name}<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"466\" height=\"24\" class=\"wp-image-850\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-455.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-455.png 466w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-455-300x15.png 300w\" sizes=\"auto, (max-width: 466px) 100vw, 466px\" \/><\/p>\n<p>As you can see, the file has now been located.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"262\" height=\"30\" class=\"wp-image-851\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-456.png\" \/><\/p>\n<h2>Using find command to find files and directories in Linux<\/h2>\n<p>Compared to locate, find is a lot more powerful, but slower. It is slower because it searches through your disk for the files. What makes find great is that you can find files and directories in Linux based on user groups, when the files were modified or accessed, file permissions, dates, and size.<\/p>\n<h3>Looking for files in the current directory<\/h3>\n<p>You can view all the files with a particular name in your current directory by using the following command:<\/p>\n<pre>find . -name {filename}<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"503\" height=\"31\" class=\"wp-image-852\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-457.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-457.png 503w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-457-300x18.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-457-501x31.png 501w\" sizes=\"auto, (max-width: 503px) 100vw, 503px\" \/><\/p>\n<p>You will see all the files that have the name \u201ctextfile.txt\u201d in the current directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"546\" height=\"40\" class=\"wp-image-853\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-458.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-458.png 546w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-458-300x22.png 300w\" sizes=\"auto, (max-width: 546px) 100vw, 546px\" \/><\/p>\n<h3>Looking for files in the home directory<\/h3>\n<p>To look for files in your home directory, use <strong>\/home<\/strong>. The command will be:<\/p>\n<pre>find \/home -name {filename}<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"506\" height=\"23\" class=\"wp-image-854\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-459.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-459.png 506w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-459-300x14.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-459-501x23.png 501w\" sizes=\"auto, (max-width: 506px) 100vw, 506px\" \/><\/p>\n<p>You will see all the files named, Hello.txt in your home directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"247\" height=\"24\" class=\"wp-image-855\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-460.png\" \/><\/p>\n<h3>Ignoring case sensitivity<\/h3>\n<p>By default, find processes queries in a case-sensitive manner, meaning hello.txt and Hello.txt will point to different search results.<\/p>\n<p>As you can see, hello.txt could not be found.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"416\" height=\"39\" class=\"wp-image-856\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-461.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-461.png 416w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-461-300x28.png 300w\" sizes=\"auto, (max-width: 416px) 100vw, 416px\" \/><\/p>\n<p>To ignore case sensitivity, use the following command:<\/p>\n<pre>find \u2013iname {file name}<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"459\" height=\"26\" class=\"wp-image-857\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-462.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-462.png 459w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-462-300x17.png 300w\" sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><\/p>\n<p>As you can see in the image below, hello.txt has been located.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"474\" height=\"42\" class=\"wp-image-858\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-463.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-463.png 474w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-463-300x27.png 300w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><\/p>\n<h3>Find using wildcards<\/h3>\n<p>You can use wildcards to search for files given certain criteria. The asterisk (<strong>*<\/strong>) wildcard allows you to match instances of a character.<\/p>\n<p>The example below uses the following commands:<\/p>\n<pre>find . \u2013name \u2018*he\u2019<\/pre>\n<p>This command lists all the file names ending with \u2018he\u2019<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"592\" height=\"115\" class=\"wp-image-859\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-464.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-464.png 592w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-464-300x58.png 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/p>\n<pre>find . \u2013name \u2018he*\u2019<\/pre>\n<p>This command lists all the file names starting with \u2018he\u2019<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"329\" class=\"wp-image-860\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-465.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-465.png 621w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-465-300x159.png 300w\" sizes=\"auto, (max-width: 621px) 100vw, 621px\" \/><\/p>\n<h3>Find using file size<\/h3>\n<p>To find files based on size, use:<\/p>\n<pre>find \u2013size {filesize} \u2013type f<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"504\" height=\"28\" class=\"wp-image-861\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-466.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-466.png 504w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-466-300x17.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-466-501x28.png 501w\" sizes=\"auto, (max-width: 504px) 100vw, 504px\" \/><\/p>\n<p>This command looks for files that have a size of 68 bytes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"484\" height=\"61\" class=\"wp-image-862\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-467.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-467.png 484w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-467-300x38.png 300w\" sizes=\"auto, (max-width: 484px) 100vw, 484px\" \/><\/p>\n<p>To look up files greater than or smaller than a particular size, add \u201c<strong>+<\/strong>\u201d or \u201c<strong>&#8211;<\/strong>\u201d to your command respectively.<\/p>\n<pre>find \u2013size -{filesize} \u2013type f<\/pre>\n<p>The example below looks for files smaller than 512 bytes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"536\" height=\"30\" class=\"wp-image-863\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-468.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-468.png 536w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-468-300x17.png 300w\" sizes=\"auto, (max-width: 536px) 100vw, 536px\" \/><\/p>\n<p>This command looks for files greater than 512 bytes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"516\" height=\"29\" class=\"wp-image-864\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-469.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-469.png 516w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-469-300x17.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-469-501x29.png 501w\" sizes=\"auto, (max-width: 516px) 100vw, 516px\" \/><\/p>\n<h3>Find files based on when they were last modified<\/h3>\n<p>Use the command below to look for files based on when they were last modified:<\/p>\n<pre>find -iname \"*.txt\" -mtime -60<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"27\" class=\"wp-image-865\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-470.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-470.png 621w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-470-300x13.png 300w\" sizes=\"auto, (max-width: 621px) 100vw, 621px\" \/><\/p>\n<p>This command looks for files that were modified in the last 60 days.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"685\" height=\"260\" class=\"wp-image-866\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-471.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-471.png 685w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-471-300x114.png 300w\" sizes=\"auto, (max-width: 685px) 100vw, 685px\" \/><\/p>\n<h3>Find directories<\/h3>\n<p>To find a directory, use the command:<\/p>\n<pre>find \u2013name \u201c{file name}\u201d \u2013type d<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"555\" height=\"31\" class=\"wp-image-867\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-472.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-472.png 555w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-472-300x17.png 300w\" sizes=\"auto, (max-width: 555px) 100vw, 555px\" \/><\/p>\n<p>You can see the path to the directory as a result.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"548\" height=\"41\" class=\"wp-image-868\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-473.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-473.png 548w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-473-300x22.png 300w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><\/p>\n<h3>Find read-only files<\/h3>\n<p>To find read-only files, use the command<\/p>\n<pre>find \/ -perm \/u=r<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"431\" height=\"31\" class=\"wp-image-869\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-474.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-474.png 431w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-474-300x22.png 300w\" sizes=\"auto, (max-width: 431px) 100vw, 431px\" \/><\/p>\n<p>You can see all the read-only files in the terminal.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"445\" height=\"223\" class=\"wp-image-870\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-475.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-475.png 445w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-475-300x150.png 300w\" sizes=\"auto, (max-width: 445px) 100vw, 445px\" \/><\/p>\n<h2>Using Grep command to find files and directories in Linux<\/h2>\n<p>Grep, Global Regular Expression Print is used in Linux to find strings in a particular file. If grep finds those characters, it prints the line. The command is:<\/p>\n<pre>grep {string} {file name}<\/pre>\n<p>In the example below, we\u2019ll be searching for the string \u201cis\u201d in the file \u201ctextfile.txt\u201d. You can see the lines that contain the \u201cis\u201d.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"649\" height=\"61\" class=\"wp-image-871\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-476.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-476.png 649w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-476-300x28.png 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/p>\n<h3>Print line numbers<\/h3>\n<p>You print out the line numbers along with the matching string using:<\/p>\n<pre>grep {string} {filename} \u2013n<\/pre>\n<p>The example below prints the line number where the string \u201cis\u201d is found.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"535\" height=\"40\" class=\"wp-image-872\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-477.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-477.png 535w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-477-300x22.png 300w\" sizes=\"auto, (max-width: 535px) 100vw, 535px\" \/><\/p>\n<h3>Invert Match<\/h3>\n<p>This option lets you print the lines that do not match the pattern you entered.<\/p>\n<pre>grep {string} {file name} \u2013v<\/pre>\n<p>The example below prints out the line from the text file \u201ctextfile.txt\u201d that does not contain \u201cis\u201d.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"44\" class=\"wp-image-873\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-478.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-478.png 493w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-478-300x27.png 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><\/p>\n<h3>Ignoring case sensitivity<\/h3>\n<p>By default, grep processes queries in a case-sensitive manner, meaning, is and IS will point to different search results.<\/p>\n<p>As you can see, \u201cIS\u201d could not be found.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"453\" height=\"42\" class=\"wp-image-874\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-479.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-479.png 453w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-479-300x28.png 300w\" sizes=\"auto, (max-width: 453px) 100vw, 453px\" \/><\/p>\n<p>Use the command below to ignore case:<\/p>\n<pre>grep {string} {file name} \u2013i<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"483\" height=\"37\" class=\"wp-image-875\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-480.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-480.png 483w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-480-300x23.png 300w\" sizes=\"auto, (max-width: 483px) 100vw, 483px\" \/><\/p>\n<h3>Recursive search<\/h3>\n<p>Grep does not let you search directories, by default. You get the following error:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"373\" height=\"41\" class=\"wp-image-876\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-481.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-481.png 373w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-481-300x33.png 300w\" sizes=\"auto, (max-width: 373px) 100vw, 373px\" \/><\/p>\n<p>You can search within directories using:<\/p>\n<pre>grep {string} . \u2013R<\/pre>\n<p>The example below searches for the string \u201csome\u201d in the current directory.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"507\" class=\"wp-image-877\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-482.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-482.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2020\/10\/word-image-482-300x209.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<p>In this article, we saw how locate, find, and grep work to find files and directories in Linux. We also went through some cases on how they are used.<\/p>","protected":false},"excerpt":{"rendered":"<p>This article will go through how you can find files and directories in Linux. We will be using the locate, find, and grep command. Each command is discussed&hellip;<\/p>","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[47],"class_list":["post-842","post","type-post","status-publish","format-standard","hentry","category-ubuntu","tag-directories"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=842"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/842\/revisions"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}