logrotate log files - keeping in order when using grep or cat and bash
I'm trying to sort through some Squid log files that have been rotated with logrotate. These files are named
The oldest file is #28 and the newest file is access.log. The individual files are from oldest on the top to newest.
If I'd like to sort through all of these files, I would do something like:
zgrep 'pattern' access.log*
but the order isn't too useful. I've tried
zgrep 'pattern' access.log.[1-2][0-9].gz access.log.[1-9].gz access.log
but the pattern is 10-28,1-9,access.log instead of 28-1,access.log. I've tried writing the order backwards (i.e., [2-1][9-0]) but that doesn't work.
How can I get this to ouput correctly? Do I need to use the 'find' statement or create a shell script of some sort? I've played with
for file in $(ls access.log.[1-9].gz access.log.[1-3][0-9].gz); do echo $file; done
but that doesn't seem to help either.