Issue
I have log file in tomcat logs and I want to write a script to merge last 7 days log files.
Log file names catalina.2015-04-23.log
, catalina.2015-06-05.log
, catalina.2015-06-04.log
.
Solution
This will produce the merged log file for 1 week
for a in `seq 6 -1 0`;
do
dt=`date "+%F" --date=" -"$a" days"`;
f=$dt".log";
cat $f >> "1_week.log";
done;
Answered By - shanmuga Answer Checked By - Pedro (WPSolving Volunteer)