Ubuntu – List all recently changed files (recursive)

command linelssearch

So, I want to display (via ls for example) all files, which were changed in the last seven days. If I'm in my docroot-folder, it should be able to look "deeper".

For example:

File        Last changed
docroot
|- myfile1  30.11.2015
|- myfile2  10.11.2015
|- MySub
   |-sub1   30.11.2015
   |-sub2   10.11.2015

So, the ls (or whatever fits) should output myfile1 and (if possible)
MySub/sub1.

Is this doable with one command?

Best Answer

Of course. From the directory you are in do:

find . -type f -mtime -7 -exec ls -l {} \; 

Add a redirection to it (aka > results.txt to store them into that file).

  • type f does only files and not directories
  • mtime -7 does 7 days ago up to now (+7 would be 'older than 7 days')
  • and it then feeds it to ls to show a long list

You can play with the ls -l part too:

find . -type f -mtime -7 -exec ls -Rl --time-style=long-iso {} \; 
find . -type f -mtime -7 -exec ls -R  --time-style=long-iso {} \; 

will show a tree like method with directories in between the files in long list (1) or short list (2).