Try :
find $folder -type f -name foo*.tgz -not -newer foo2.tgz -exec ls -l {}\;
Once the result fits your needs, replace
ls -l {} \;
by
rm -f {} \;
That works with 1 file you've just added, but parsing a whole directory and determine the root name of each file to delete older ones is another story, the naming convention must be strict.
Let us know.
|