Im trying to make some backup script as the log files get bigger and bigger. What i have is coping the current file, (for example secure
file in /var/log/
) and remove the content from that file. But there are some files with the name like: secure.1
, secure.2
and all this i like to count them, and if the number is bigger then 2
to archive them all. I can't find the method to find this files or count them. The first think that come up to me was:
find /var/log/ -name *.1 | wc -l
and this will always print 1
as there is one file secure.1
. How can i count like in for loop where i can specified a range of numbers like {1..5}
or similar. Is there a way to separate this files and make them as one and them backup or delete or what ever ... or first of all how can i find all this numbers that ends up with number.
find /var/log/ -name '*.1' ...
logrotate
for your purpose.