44

see i am working in one BIG project source code Now i want to know which files are modified after some date.

Is there any command or any way to get that..

i have tried

# ls -R -l 

but here it shows all file with last modified data but i want to filter this output by some data ...

so is there any way to do this in linux? is there any tool available for this?

Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222

3 Answers3

85
#set timestamp for file    
touch --date "2011-12-31" /tmp/foo
# Find files newer than 2011/Dec/31, in /some/files
find /some/files -newer /tmp/foo
peko
  • 11,267
  • 4
  • 33
  • 48
  • 12
    After a specific time: touch -d '2011-12-31 10:22' /tmp/foo – Ra. Jan 17 '14 at 16:51
  • 1
    what is /tmp/foo? How can I do this: find files in this-directory that mmtime > this-date and save it as variable lst? Thank you – Ali Khosro Apr 26 '18 at 08:10
  • `/tmp/foo` is an arbitrary file that is just used to compare the date too. It is placed in `/tmp` as it is a temporary file. – thoni56 Feb 20 '23 at 10:33
36

Use find command with mtime arguments: Some examples are here or here

For example, list files changed in last 7 days...

find / -type f -mtime -7 

For fine grained search you may try -mmin argument. See an example discussed in another SE site: Find All files older than x minutes

Community
  • 1
  • 1
Jayan
  • 18,003
  • 15
  • 89
  • 143
  • 1
    The problem with mtime is that it's too coarse. If you have files modified 6 hours ago and 8 hours ago, you can't distinguish them with find. You'll need to use [peko's workaround](http://stackoverflow.com/a/8986162/111424). – Iain Samuel McLean Elder Jan 18 '14 at 14:14
  • This command gives the files modified 7*24 hours ago not those which got changed in last 7 days. – Jaydeep Ranipa Jul 03 '17 at 05:11
  • Is there away to to skip certain subfolders with a speficic keywords(s) stay "cache" and "log"? for example. ```find / -type f -mtime -7 -skip "cache,log" ?``` thanks. – Ahdee Jul 13 '17 at 02:14
  • 1
    The example with `-mtime -7` does find all objects changed in the last 7 days. Not just 7*24 ago. – NoelProf Jan 30 '18 at 18:12
2

You should use find with -newerXY option.

  • m – modification time of the file reference
  • t – reference is interpreted directly as a time

All files modified after 2022-12-01 (inclusive):

find . -type f -newermt 2022-12-01
Konstantin Smolyanin
  • 17,579
  • 12
  • 56
  • 56