File concat program
Posted on 2004-09-03
I'm tryting to do the following:
I have all my webstats in one folder of mt Linux box ( /var/log/httpd)
They are listed as follow:
( note, dom1 and dom2 are only examples, there are no usable patterns in the part infront of the -access.log)
I would now like to have a script that can run through the folder to concat all the files for one particular dom into one file
ie, I want to combine dom1-access.log, dom1-access.log.1, dom1-access.log.2 , dom-access.log.3 etc into just dom1-access.log, ie, add the contents of the rolled logs to the "current" log file. The trick would also be to construct the new file as follow:
Since dom1-access.log.x (where x is the largest of whatever is present ( the log roller will go up to .4 I think)) is the "oldest" and it's data needs to be added to the "new" dom1-access.log file, then the dom1-access.log.3, then ...2, then ....1, and finaly the original dom1-access.log contents..
Can someone pls give me some pointers/examples since I am not very familiar with Perl, but Perl ( or Bash) is the only scripting language available to me on the server.