#!/usr/bin/perl -w ######################################## # Modules use strict; # parameter Definition before use them use File::Copy; use DateTime; # Libary for Date operation ####################################### # Parameter Definition my ($ct,$idx,$idx2,$idx3,$numbers,$inPut,$outPut); # counter parameter my $tstamp = DateTime->now->set_time_zone('Europe/Berlin'); # Find the Timestamp my $mydate = $tstamp->ymd; my $folder = "./workingFolder"; my $OutFolder = "./workingFolder/ReadyLogs/"; my $preFix = "server.log"; my (@filelist,@lines); ########################### # Main system("clear"); @filelist = glob($folder.'/server.log.*'); #print join("\n", @filelist,"\n"); rename($folder."/server.log",$folder."/01.log"); $idx = 11; $idx2 = $idx-1; for($ct=1;$ct<=10;$ct++){ # print `pwd`; # Output working directory $idx =sprintf("%02d",$idx); # Put Zero in Front $inPut =$folder."/".$preFix.".".$idx2; $outPut =$folder."/".$idx.".log"; # print "Input: $inPut, Output: $outPut \n"; rename($inPut,$outPut) || die "Error during Rename: $!"; $idx--; $idx2--; } for($ct=11;$ct>0;$ct--){ open(INFile,"<",$folder."/".$ct.".log"); open(OFile,">>",$OutFolder."/".$mydate."-ServerMessages.log"); @lines=; print OFile @lines; close(INFile); }