0

I'm currently writing a clean up script and for that i need a list of folder without any changes to subfiles or subdiretories. Right now i have this as a base. (Would like it to be untouched for the last 14 days)

find ./* -type f -mtime -14

Which will generate a list of any untouched files and directories. The problem is that this one will generate a list where some directories might show up any way because there only been changes to a couple of files within some of the subdirectories.

Does anyone have any idea how to generate a list of completely untouched directories?

cheers!

tso
  • 4,732
  • 2
  • 22
  • 32
Mathias Wrobel
  • 389
  • 2
  • 11
  • You might want to read [this question about what constitutes a modification in a directory](https://stackoverflow.com/questions/3451863/when-does-a-unix-directory-change-its-timestamp). According to this info, your directories whose subdirectories have been changed shouldn't be listed. – Aaron Oct 27 '17 at 14:20
  • Also you say your command "will generate a list of any untouched files and directories", but since you've added a `-type f` selector to your `find` command I doubt it lists any directory at all. – Aaron Oct 27 '17 at 14:22
  • Doesn't `-14` mean to find files that have been modified no more than 14 days ago? Don't you want files that have NOT been modified in the last 14 days? I think `+14` is what you might want, unless i'm not understanding. – A Brothers Oct 27 '17 at 14:49
  • You need a list of files/dirs that *have* changed, and a list of all. If something has changed, that directory has a change and should be kept, as should its parent tree. If nothing in a directory has changed it can go. This is largely a matter of sorting both lists and walking them in sync, using the changes list as the driver. Am I understanding what you need correctly? – Paul Hodges Oct 27 '17 at 19:55

0 Answers0