{"id":569,"date":"2019-03-11T17:34:32","date_gmt":"2019-03-11T17:34:32","guid":{"rendered":"http:\/\/linuxresellerwebhosting.in\/blog\/?p=569"},"modified":"2019-04-01T20:35:26","modified_gmt":"2019-04-01T20:35:26","slug":"usage-of-find-command-with-examples","status":"publish","type":"post","link":"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/","title":{"rendered":"Usage of Find Command with Examples"},"content":{"rendered":"<h2><span class=\"ez-toc-section\" id=\"Hi_All\"><\/span>Hi All,<span class=\"ez-toc-section-end\"><\/span><\/h2><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#Hi_All\" >Hi All,<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#1_Find_Files_Using_Name_in_Current_Directory\" >1. Find Files Using Name in Current Directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#2_Find_Files_Under_Home_Directory\" >2. Find Files Under Home Directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#3_Find_Files_Using_Name_and_Ignoring_Case\" >3. Find Files Using Name and Ignoring Case<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#4_Find_Directories_Using_Name\" >4. Find Directories Using Name<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#5_Find_HTML_Files_Using_Name\" >5. Find HTML Files Using Name<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#6_Find_all_PHP_Files_in_Directory\" >6. Find all PHP Files in Directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#7_Find_Files_With_644_Permissions\" >7. Find Files With 644 Permissions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#8_Find_Files_Without_644_Permissions\" >8. Find Files Without 644 Permissions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#9_Find_all_Empty_Files\" >9. Find all Empty Files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#10_Find_all_Empty_Directories\" >10. Find all Empty Directories<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/usage-of-find-command-with-examples\/#11Find_Specific_Files_and_Delete\" >11.Find Specific Files and Delete<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n<p><strong>Find<\/strong> is a very important command for system administrator to do their daily works. Most of the Linux distribution&#8217;s comes prepacked with the &#8220;find&#8221; command tool to search for files. Now lets see how to use find command with examples.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_Find_Files_Using_Name_in_Current_Directory\"><\/span><strong>1. Find Files Using Name in Current Directory<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Find all the files whose name is test.txt in a current working directory.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \"># find . -name test.txt\r\n\r\n.\/test.txt<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2_Find_Files_Under_Home_Directory\"><\/span><strong>2. Find Files Under Home Directory<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Find all the files under \/home directory with name test.txt.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \"># find \/home -name test.txt\r\n\r\n\/home\/test.txt<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"3_Find_Files_Using_Name_and_Ignoring_Case\"><\/span><strong>3. Find Files Using Name and Ignoring Case<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Find all the files whose name is tecmint.txt and contains both capital and small letters in \/home directory.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true\"># find \/home -iname test.txt\r\n\r\n.\/test.txt\r\n.\/test..txt\r\n\r\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"4_Find_Directories_Using_Name\"><\/span><strong>4. Find Directories Using Name<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Find all directories whose name is test in \/ directory.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \"># find \/ -type d -name test\r\n\r\n\/test<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"5_Find_HTML_Files_Using_Name\"><\/span><strong>5. Find HTML Files Using Name<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Find all php files whose name is test.html in a current working directory.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \"># find . -type f -name test.html\r\n\r\n.\/test.html\r\n\r\n<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"6_Find_all_PHP_Files_in_Directory\"><\/span><strong>6. Find all PHP Files in Directory<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Find all html files in a directory.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \"># find . -type f -name \"*.html\"\r\n\r\n.\/test.html\r\n.\/login.html\r\n.\/index.html<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"7_Find_Files_With_644_Permissions\"><\/span><strong>7. Find Files With 644 Permissions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Find all the files whose permissions are 644.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \"># find . -type f -perm 0644<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"8_Find_Files_Without_644_Permissions\"><\/span><strong>8. Find Files Without 644 Permissions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Find all the files without permission 644.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \"># find \/ -type f ! -perm 644<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"9_Find_all_Empty_Files\"><\/span><strong>9. Find all Empty Files<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To find all empty files under certain path.<\/p>\n<pre class=\"theme:dark-terminal lang:default decode:true \"># find \/tmp -type f -empty<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"10_Find_all_Empty_Directories\"><\/span>10. Find all Empty Directories<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To file all empty directories under certain path.<\/p>\n<pre class=\"\"><strong># find \/tmp -type d -empty<\/strong><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"11Find_Specific_Files_and_Delete\"><\/span><strong>11.Find Specific Files and Delete<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Find all .mp4 files with more than 50MB and delete them using one single command.<\/p>\n<p># find \/ -type f -name *.mp4 -size +50M -exec rm {} \\;<\/p>\n<p>&nbsp;<\/p>\n<p>Thanks for reading this tutorial, Hope you have enjoyed it \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi All, Find is a very important command for system administrator to do their daily works. Most of the Linux<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[2],"tags":[],"class_list":["post-569","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=569"}],"version-history":[{"count":1,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/569\/revisions"}],"predecessor-version":[{"id":571,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/569\/revisions\/571"}],"wp:attachment":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}