Skip to main content
deleted 19 characters in body; edited title
Source Link
Braiam
  • 36.9k
  • 29
  • 114
  • 176

delete Delete subfolder and keeping up parent folder

I am trying to find solution for next: i need to delete folderx which are not accessed for seven days, easily iI can do it with next:

find /path/folder -type d -mtime +7 |xargs rm -rf

find /path/folder -type d -mtime +7 |xargs rm -rf

But theThe probelm is when iI have subfolder marked for deletion and parent folder is not, iI can do it with with adding maxdepth 1, but actually it is not solution from top to bottom, iI need solution to define from bottom to top where iI have folder 1 (accesed 8 days ago) -> folder 2 (accessed 8 days ago) -> folder 3 (accessed 4 days ago),

folder 1 (accesed 8 days ago)
-> folder 2 (accessed 8 days ago)
-> folder 3 (accessed 4 days ago),

withWith maxdepth 1 it will delete first two and also folder 3 which i dontI don't want do do it. So

So actually iI need some solution from bottom to top for this. If subfolder is marked for deletion and parent is not etc.

delete subfolder and keeping up parent folder

I am trying to find solution for next: i need to delete folderx which are not accessed for seven days, easily i can do it with next:

find /path/folder -type d -mtime +7 |xargs rm -rf

But the probelm is when i have subfolder marked for deletion and parent folder is not, i can do it with with adding maxdepth 1, but actually it is not solution from top to bottom, i need solution to define from bottom to top where i have folder 1 (accesed 8 days ago) -> folder 2 (accessed 8 days ago) -> folder 3 (accessed 4 days ago),

with maxdepth 1 it will delete first two and also folder 3 which i dont want do do it. So actually i need some solution from bottom to top for this. If subfolder is marked for deletion and parent is not etc.

Delete subfolder and keeping up parent folder

I need to delete folderx which are not accessed for seven days, easily I can do it with next:

find /path/folder -type d -mtime +7 |xargs rm -rf

The probelm is when I have subfolder marked for deletion and parent folder is not, I can do it with with adding maxdepth 1, but actually it is not solution from top to bottom, I need solution to define from bottom to top where I have

folder 1 (accesed 8 days ago)
-> folder 2 (accessed 8 days ago)
-> folder 3 (accessed 4 days ago),

With maxdepth 1 it will delete first two and also folder 3 which I don't want do do it.

So actually I need some solution from bottom to top for this. If subfolder is marked for deletion and parent is not etc.

Source Link
klerk
  • 2.9k
  • 2
  • 19
  • 16

delete subfolder and keeping up parent folder

I am trying to find solution for next: i need to delete folderx which are not accessed for seven days, easily i can do it with next:

find /path/folder -type d -mtime +7 |xargs rm -rf

But the probelm is when i have subfolder marked for deletion and parent folder is not, i can do it with with adding maxdepth 1, but actually it is not solution from top to bottom, i need solution to define from bottom to top where i have folder 1 (accesed 8 days ago) -> folder 2 (accessed 8 days ago) -> folder 3 (accessed 4 days ago),

with maxdepth 1 it will delete first two and also folder 3 which i dont want do do it. So actually i need some solution from bottom to top for this. If subfolder is marked for deletion and parent is not etc.