{"id":48,"date":"2011-04-23T22:57:23","date_gmt":"2011-04-23T22:57:23","guid":{"rendered":"http:\/\/www.plugged.in\/?p=48"},"modified":"2011-04-23T22:57:23","modified_gmt":"2011-04-23T22:57:23","slug":"linux-recursive-search-inside-files","status":"publish","type":"post","link":"https:\/\/www.veriteknik.net.tr\/en\/linux-recursive-search-inside-files\/","title":{"rendered":"Linux Recursive Search inside files"},"content":{"rendered":"<p>You can make a search inside files within a a directory using the command &#8220;<strong>find<\/strong>&#8220;, to do that:<\/p>\n<ul>\n<li><strong>with the find command<br \/>\n<\/strong><\/li>\n<\/ul>\n<blockquote>\n<div>cd \/to_folder<br \/>\nfind . -iname &#8216;*conf&#8217; | xargs grep &#8216;string&#8217; -sl<\/div>\n<\/blockquote>\n<p>-iname &#8216;*conf&#8217; states that the seach will only check the files ending with *conf,<br \/>\nusing -iname &#8216;*&#8217; will search inside all the files within the current directory.<br \/>\ngrep &#8216;string&#8217; is the query string that you ment to search for.<\/p>\n<p>If you only want to make a search based on the file names you should better use &#8220;locate&#8221; since it has an indexing feature to make faster searches:<\/p>\n<blockquote>\n<div>updatedb<br \/>\nlocate filename<\/div>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<p>If you don&#8217;t have the locate command, you can install it with the yum installer:<\/p>\n<blockquote>\n<div>updatedb<br \/>\nyum install mlocate<\/div>\n<\/blockquote>\n<ul>\n<li><strong>Find files based on their size<\/strong><\/li>\n<\/ul>\n<p>With the below command you can find the files greater than 100 MBs.<\/p>\n<blockquote>\n<div>find \/folder\/ -type f -size +100000k -exec ls -lh {} \\; | awk &#8216;{ print $9 &#8220;: &#8221; $5 }&#8217;<\/div>\n<\/blockquote>\n<ul>\n<li><strong>Find files based on their modification date<br \/>\n<\/strong><\/li>\n<\/ul>\n<p>With the below command you can find the files based on their modification date., if you write ctime instead of mtime you can list the files created within two days.:<\/p>\n<blockquote>\n<div>find \/folder\/ -type f -mtime -2 -exec ls -lh {} \\; | awk &#8216;{ print $9 &#8220;: &#8221; $5 }&#8217;<\/div>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>You can make a search inside files within a a directory using the command &#8220;find&#8220;, to do that: with the find command cd \/to_folder find . -iname &#8216;*conf&#8217; | xargs grep &#8216;string&#8217; -sl -iname &#8216;*conf&#8217; states that the seach will only check the files ending with *conf, using -iname &#8216;*&#8217; will search inside all the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[372],"tags":[371,407],"yst_prominent_words":[1528,1522,1512,1524,1513,1510,1521,1511,1509,1520,1516,1519,1518,1526,1525,1514,1527,1515,1517,1523],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-linux_help","tag-linux-2","tag-search"],"jetpack_featured_media_url":"","uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"ckaraca","author_link":"https:\/\/www.veriteknik.net.tr\/en\/author\/ckaraca\/"},"uagb_comment_info":0,"uagb_excerpt":"You can make a search inside files within a a directory using the command &#8220;find&#8220;, to do that: with the find command cd \/to_folder find . -iname &#8216;*conf&#8217; | xargs grep &#8216;string&#8217; -sl -iname &#8216;*conf&#8217; states that the seach will only check the files ending with *conf, using -iname &#8216;*&#8217; will search inside all the&hellip;","_links":{"self":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":0,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/tags?post=48"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/www.veriteknik.net.tr\/en\/wp-json\/wp\/v2\/yst_prominent_words?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}