Hi, I need some help to write a script
i need to write script that will count the no of logs generated for the day and specify the logfiles names which is not generated for the day.
Default no of log generate per day is 29
if less than 29 logs generated it should specify the perticular logfile name.
The lofiles are like
a.log
b.log
c.log
The logs are generated everyday in a perticular directory location and with datestamp like (Jul 10) (Jul 9) etc.
#!/bin/sh
Date=`date +"%b %d"`
cd /prod/logs
printf "No of log files are\n"
ls -ltr |grep "$Date"|wc -l
ls -ltr |grep "$Date"|awk '{print $9}'>>b.txt
mv b.txt /home/sid_ap
cd /home/sid_ap
printf "No log file for\n"
comm -13 a.txt b.txt
But this is not showing the proper o/p for dates like Jul 1, Jul 2.
However, i am getting the o/p fine for Jul 10, Jul 11 .
Also when it compares the two files (a.txt and b.txt) it is giving o/p b.txt as default.
---------- Post updated at 03:51 PM ---------- Previous update was at 03:24 PM ----------
I have corrected the date problem using %e instead of %d.
can some one help me out why the b.txt coming as o/p when i am comparing the 2 files.
i am getting a o/p like this :
No of log files are
29
No log file for
b.txt
Though a.txt and b.txt contains same no of logfiles i am getting b.txt as o/p.
Thanks,
but it is not resolving the problem. gives me the same o/p.
i got the problem
ls -ltr |grep "$Date"|awk '{print $9}'>>b.txt
this line of code is adding an extra value b.txt to the file b.txt. Thats why the o/p is coming like this.
Can anybody tell me why it is coming? or how can i rectify that?