Results 1 to 3 of 3
Hi All,
I have a huge folder of around 50G in size and have different subdirectories. I want to create a script that can find the files older than different ...
- 09-11-2008 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 49
help - script to delete the files
Hi All,
I have a huge folder of around 50G in size and have different subdirectories. I want to create a script that can find the files older than different dates for some of the subdirectories and delete the files.
I assume to exclude the subdirectory-1 and subdirectory-2 from the following command and delete all files older then 15 days for all other subdirectories.
find /../rootdirectory/ -type f -daystart -mtime +15 -not -path '/rootdirectory/subdirectory-1/' -not -path '/rootdirectory/subdirectory-1/' -not -path -exec rm {} \;
find /../rootdirectory/subdirectory-1/ -type f -daystart -mtime +30 -exec rm {} \;
find /../rootdirectory/subdirectory-2/ -type f -daystart -mtime +60 -exec rm {} \;
Well this is not working for me
If someone can suggest some otherway to do this I would really appreciate.
Many thanks.
- 09-11-2008 #2
for excluding folders you can use prune.
have a look at the find man pageLinux and me it's a love story
- 09-15-2008 #3
What is not working for you? Is it a syntax error? Is it deleting things from the subdirectories that it shouldn't be? Is it not deleting anything?
The -path directive is going to try to match against the entire pathname. So it is going to see "/rootdirectory/subdirectory-1/foo" and see if it is "/rootdirectory/subdirectory-1". It is not, so it will try to delete this.
Try using:
Note the single quotes around the *: you need to be sure that the shell doesn't try to interpolate the asterisk itself.Code:-not -path /rootdirectory/subdirectory-1/'*'
DISTRO=Arch
Registered Linux User #388732


Reply With Quote