charmander
New Member
Hello friends.
I have some doubts about the find command.
I need to create a command to search and remove directories with more than 30 days without modification, but there are directories with more than 30 days without modification that must remain on the server.
So, I created a command, but it doesn't work and I don't know how to make it work:
find /directory -type d -mtime +30 -exec rm -rf !(directories-which-cannot-be-excluded) \;
I created a shell script to perform a cleanup, but it would delete everything, not just files older than 30 days without modification.
#!/bin/bash
cd / directory
rm -rf !(file-which-cannot-be-excluded)
Is there a way to exclude directories with more than 30 days without modification, keep some directories with more than 30 days without modification and keep those with less than 30 days of creation?
I have some doubts about the find command.
I need to create a command to search and remove directories with more than 30 days without modification, but there are directories with more than 30 days without modification that must remain on the server.
So, I created a command, but it doesn't work and I don't know how to make it work:
find /directory -type d -mtime +30 -exec rm -rf !(directories-which-cannot-be-excluded) \;
I created a shell script to perform a cleanup, but it would delete everything, not just files older than 30 days without modification.
#!/bin/bash
cd / directory
rm -rf !(file-which-cannot-be-excluded)
Is there a way to exclude directories with more than 30 days without modification, keep some directories with more than 30 days without modification and keep those with less than 30 days of creation?