Saturday, 23 November 2013

How to find files modified on a particular date

Recently my client came up with a request that, he wanted to know all the files that was modified on a particular day in his server. I knew "find" will be a good option but "how?" was the question.

Then I came up with a solution as follows:

SYNTAX:  find /path/to/dir -newermt "date"
 ======

To find out all files that has been modified on a particular day(2013-11-23).
====
[root@ ~]# find /home/manoj/ -type f -name "*" -newermt 2013-11-23 ! -newermt 2013-11-24
/home/manoj/test
=====

To find out all the files between a particular date, that is 2013-11-22 and 2013-11-24.
====
[root@~]# find /home/manoj/ -type f -name "*" -newermt 2013-11-22 ! -newermt 2013-11-24
/home/manoj/test
[root@~]#
====

 To find out all files that has ".html" suffix and has been modified on 2013-11-23
 ====
[root@ ~]# find /home/manoj/ -type f -name "*.html" -newermt 2013-11-23 ! -newermt 2013-11-24
/home/manoj/index.html
 ====

Hope that helps :)



No comments:

Post a comment

Note: only a member of this blog may post a comment.