Channelling the Techno-Zeitgeist

May 10, 2009 13:51

Current Music: Silence

Dear Lazyweb,

The way Apache names its access logs is causing me grief and, because my bashfu is weak, I'm calling on you for assistance.

Specifically, the most recent access logfile is named "DOMAIN-access.log" (where "DOMAIN" is the name of the logged domain, obviously); the next most recent "DOMAIN-access.log.1"; the one after that is "DOMAIN-access.2.gz"; then "DOMAIN-access.3.gz" to "DOMAIN-access.N.gz." (Obviously, each time the standard log rotation script runs it renames all the old files-although thankfully it leaves the dates intact. And to make things trickier, it gzips everything older than the ".1" log.)

I need to send a (plaintext) stream of all of the log file entries from all of the access logfiles for the domain to awstats, but in order to do that I need to craft a single line something like this:

gunzip -dc `ls -tr DOMAIN-access*.gz` [MAGIC] cat DOMAIN-access.log.1 DOMAIN-access.log

(The actual DOMAINNAME.awstats.conf file line needs to read: LogFile="gunzip...")

So, what shell MAGIC (assuming I can't just make a giant string and concatenate it to another giant string) do I need to use to get the output of the cat to follow the output of the gunzip into the stdout stream?

[Update: A missing "-" was the problem.]
Previous post Next post
Up