{"id":337,"date":"2010-02-08T12:19:22","date_gmt":"2010-02-08T10:19:22","guid":{"rendered":"http:\/\/www.shukko.com\/x3\/?p=337"},"modified":"2010-02-08T12:19:22","modified_gmt":"2010-02-08T10:19:22","slug":"find-ek-find-files-by-access-modification-date-under-linux-or-unix","status":"publish","type":"post","link":"https:\/\/www.shukko.com\/x3\/2010\/02\/08\/find-ek-find-files-by-access-modification-date-under-linux-or-unix\/","title":{"rendered":"find ek &#8211; Find files by access, modification date under Linux or UNIX"},"content":{"rendered":"<p>Q. I don&#8217;t remember where I saved pdf and text files under Linux. I have downloaded files from internet a few months ago. How do I find my pdf files?<\/p>\n<p>A. You need to use find command. Each file has three time stamps, which record the last time that certain operations were performed on the file:<br \/>\n[a] access (read the file&#8217;s contents) &#8211; atime<\/p>\n<p>[b] change the status (modify the file or its attributes) &#8211; ctime<\/p>\n<p>[c] modify (change the file&#8217;s contents) &#8211; mtime<\/p>\n<p>You can search for files whose time stamps are within a certain age range, or compare them to other time stamps.<\/p>\n<p>You can use -mtime option. It returns list of file if the file was last accessed N*24 hours ago. For example to find file in last 2 months (60 days) you need to use -mtime +60 option.<\/p>\n<ul>\n<li><strong>-mtime +60<\/strong> means you are looking for a file modified 60 days ago.<\/li>\n<li><strong>-mtime -60<\/strong> means less than 60 days.<\/li>\n<li><strong>-mtime 60 <\/strong>If you skip + or &#8211; it means exactly 60 days.<\/li>\n<\/ul>\n<p>So to find text files  that were last modified 60 days ago, use<br \/>\n<code>$ find \/home\/you -iname \"*.txt\" -mtime -60 -print<\/code><\/p>\n<p>Display content of file on screen that were last modified 60 days ago, use<br \/>\n<code>$ find \/home\/you -iname \"*.txt\" -mtime -60 -exec cat {} \\; <\/code><\/p>\n<p>Count total number of files using wc command<br \/>\n<code>$ find \/home\/you -iname \"*.txt\" -mtime -60 | wc -l<\/code><\/p>\n<p>You can also use access time to find out pdf files. Following command will print the list of all pdf file that were accessed in last 60 days:<br \/>\n<code>$ find \/home\/you -iname \"*.pdf\" -atime -60 -type -f<\/code><\/p>\n<p>List all mp3s that were accessed exactly 10 days ago:<br \/>\n<code>$ find \/home\/you -iname \"*.mp3\" -atime 10 -type -f<\/code><\/p>\n<p>There is also an option called -daystart. It measure times from the beginning of today rather than from 24 hours ago. So, to list the all mp3s in your home directory that were accessed yesterday, type the command<br \/>\n<code>$ find \/home\/you -iname \"*.mp3\" -daystart -type f -mtime 1 <\/code><\/p>\n<p>Where,<\/p>\n<ul>\n<li><strong>-type f<\/strong> &#8211; Only search for files and not directories<\/li>\n<\/ul>\n<p>Read man page of find command for more information.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Q. I don&#8217;t remember where I saved pdf and text files under Linux. I have downloaded files from internet a few months ago. How do I find my pdf files? A. You need to use find command. Each file has three time stamps, which record the last time that certain operations were performed on the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-337","post","type-post","status-publish","format-standard","hentry","category-kategerisiz"],"_links":{"self":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/comments?post=337"}],"version-history":[{"count":1,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/337\/revisions"}],"predecessor-version":[{"id":338,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/337\/revisions\/338"}],"wp:attachment":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/media?parent=337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/categories?post=337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/tags?post=337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}