Here is an example of the logs in the / var / www / apache 2 / log folder -
./no_domain_access.log.7.gz
./no_domain_access.log.8.gz
./no_domain_access.log.9.gz
./no_domain_error.log.10.gz
./no_domain_error.log.11.gz
./no_domain_error.log.12.gz
./no_domain_error.log.13.gz
./no_domain_error.log.14.gz
./no_domain_error.log.15.gz
./no_domain_error.log.16.gz
./no_domain_error.log.17.gz
./no_domain_error.log.18.gz
./no_domain_error.log.19.gz
./no_domain_error.log.20.gz
and up to 50 ...
I would like to iterate over these files and delete all log files that are greater than 5.
using regex syntax will give me the opportunity to match the numbers in the pattern [1-9] or {1,2}, but it will also correspond to those log files that I do not want to delete (single numbers 1-5 log files that I want to save )
How can I match only file names with numbers above 5?
Thank!
Jamz source
share