{"id":426,"date":"2009-10-07T06:06:16","date_gmt":"2009-10-07T06:06:16","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/index.php\/?p=426"},"modified":"2009-10-07T06:06:16","modified_gmt":"2009-10-07T06:06:16","slug":"find","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/find\/","title":{"rendered":"Find"},"content":{"rendered":"<p>With hard drives becoming real cheap over the past few years we\u2019ve grown accustomed to having many gigabytes or sometimes even terabytes of data on our computers. This is when being able to find information on our computers becomes important. Linux has a very handy command line tool very aptly called \u201cfind\u201d. I\u2019ll share with you some basic features of the \u201cfind\u201d command to get you started. I\u2019m quite certain that you will find it pretty useful.<\/p>\n<p>The syntax for using \u201cfind\u201d is formed like this:<\/p>\n<p># find [where to search] [criteria]<\/p>\n<p>A simple example of its usage is:<\/p>\n<p># find -name \u201c*.txt\u201d<br \/>\n.\/Documents\/articles\/doctor_dolittle.txt<br \/>\n.\/Documents\/articles\/Installing_Redhat_Linux.txt<br \/>\n.\/Desktop\/todo_list.txt<\/p>\n<p>The above command will search the current directory and all its subdirectories for files with the \u201ctxt\u201d extension. One thing to note here is that all the parameters for find are completely optional. This means that even if you just enter the \u201cfind\u201d command and hit the Enter key you will get a result \u2013 a list of all the in the current directory and the subdirectories. Try it out.<\/p>\n<p>If you want to search multiple directories for text files you can list the directories to search in one after another:<\/p>\n<p># find \/home\/hobbes\/ \/home\/calvin\/ -name \u201c*.txt\u201d<br \/>\n\/home\/calvin\/Documents\/articles\/doctor_dolittle.txt<br \/>\n\/home\/calvin\/Desktop\/todo_list.txt<br \/>\n\/home\/hobbes\/Desktop\/articles.txt<br \/>\n\/home\/hobbes\/data_logging.txt<\/p>\n<p>You might get a few errors when you run some searches. This would mostly be related to the lack of permissions. A nice trick to make the output a lot cleaner is to send the errors to \u201c\/dev\/null\u201d:<\/p>\n<p># find \/home\/hobbes\/ \/home\/calvin\/ -name \u201c*.txt\u201d 2>\/dev\/null<\/p>\n<p>Another problem you might encounter is with the fact that by default these searches are case sensitive. So searching for \u201cpicasso\u201d will not yield the result \u201cPicasso\u201d. You can circumvent that by using the \u201c-iname\u201d option:<\/p>\n<p># find \/home\/calvin\/ -iname \u201cpicasso\u201d<br \/>\n.\/Documents\/images\/picasso.png<br \/>\n.\/Documents\/articles\/The_artist_Picasso.doc<\/p>\n<p>There are many cool \u201chacks\u201d for the \u201cfind\u201d command. Here are a few. To find files that were modified in the last 45 mins you can do a time-based search:<\/p>\n<p># find \/home\/calvin\/ -mmin -45<br \/>\n.\/hello.txt<br \/>\n.\/artwork.jpg<\/p>\n<p>Similarly you can search for files that have been modified between 15 and 25 minutes ago:<\/p>\n<p># find -mmin +15 -mmin -25<\/p>\n<p>You can also control the depth that \u201cfind\u201d goes into when searching subdirectories. The following command:<\/p>\n<p># find \/home\/calvin\/ -maxdepth 2  -name \u201c*.txt\u201d<\/p>\n<p>will only go to the top two levels of the specified directory and look for files with the \u201ctxt\u201d file extension. Optionally you can also tell \u201cfind\u201d to search only two levels lower:<\/p>\n<p># find \/home\/calvin\/ -mindepth 2  -name \u201c*.txt\u201d<br \/>\n.\/artexpo.txt<br \/>\n.\/Documents\/project.txt<\/p>\n<p>As with most commands you can append the output to a file. So if you want to log a search you can do the following:<\/p>\n<p># find \/home\/calvin\/ -name \u201c*.txt\u201d > \/tmp\/search.log<\/p>\n<p>The \u201cfind\u201d command can be extremely useful once you get the hang of it. A book can probably be written on. What I\u2019ve shared with you here is just a taste of the possibilities. Take a look at the command\u2019s manpage for pointers to other features of \u201cfind\u201d.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With hard drives becoming real cheap over the past few years we\u2019ve grown accustomed to having many gigabytes or sometimes even terabytes of data on our computers. This is when being able to find information on our computers becomes important. Linux has a very handy command line tool very aptly called \u201cfind\u201d. I\u2019ll share with&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/find\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-426","post","type-post","status-publish","format-standard","hentry","category-info"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Find - Linux Shtuff<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/g33kinfo.com\/info\/find\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Find - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"With hard drives becoming real cheap over the past few years we\u2019ve grown accustomed to having many gigabytes or sometimes even terabytes of data on our computers. This is when being able to find information on our computers becomes important. Linux has a very handy command line tool very aptly called \u201cfind\u201d. I\u2019ll share with... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/find\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2009-10-07T06:06:16+00:00\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/find\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/find\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"Find\",\"datePublished\":\"2009-10-07T06:06:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/find\\\/\"},\"wordCount\":544,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"articleSection\":[\"General Info\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/find\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/find\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/find\\\/\",\"name\":\"Find - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"datePublished\":\"2009-10-07T06:06:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/find\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/find\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/find\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Find\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Find - Linux Shtuff","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/g33kinfo.com\/info\/find\/","og_locale":"en_US","og_type":"article","og_title":"Find - Linux Shtuff","og_description":"With hard drives becoming real cheap over the past few years we\u2019ve grown accustomed to having many gigabytes or sometimes even terabytes of data on our computers. This is when being able to find information on our computers becomes important. Linux has a very handy command line tool very aptly called \u201cfind\u201d. I\u2019ll share with... Read More","og_url":"https:\/\/g33kinfo.com\/info\/find\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2009-10-07T06:06:16+00:00","author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/find\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/find\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"Find","datePublished":"2009-10-07T06:06:16+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/find\/"},"wordCount":544,"commentCount":0,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"articleSection":["General Info"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/g33kinfo.com\/info\/find\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/find\/","url":"https:\/\/g33kinfo.com\/info\/find\/","name":"Find - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"datePublished":"2009-10-07T06:06:16+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/find\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/find\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/find\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"Find"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=426"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/426\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}