Q:

Unix script for checking logs for last 10 days

I have a log table which is maintained for a single day and the data from the table is only present for one day.However, the logs for it is present in the unix directory.
My requirement is to check the logs for the last 10 days and find me the count of records got loaded.
In the log file the pattern is something like this( fastload log of teradata).
**** 13:16:49 END LOADING COMPLETE

     Total Records Read              =  443303
     Total Error Table 1             =  0  ---- Table has been dropped
     Total Error Table 2             =  0  ---- Table has been dropped
     Total Inserts Applied           =  443303
     Total Duplicate Rows            =  0

I want to the script to be parametrized( parameter will be stage table name) which find the records inserted into table and error tables for the last 10 days.
Is this possible? Can anyone help me build the unix script for this?
There are many logs in the logs directory. what if a want to check only for the below:
    bash-3.2$ ls -ltr 2018041*S_EVT_ACT_FLD*
-rw-rw----+  1 edwops   abgrp      52610 Apr 10 17:37 20180410173658_S_EVT_ACT_FLD.log
-rw-rw----+  1 edwops   abgrp      52576 Apr 11 18:12 20180411181205_S_EVT_ACT_FLD.log
-rw-rw----+  1 edwops   abgrp      52646 Apr 13 18:04 20180413180422_S_EVT_ACT_FLD.log
-rw-rw----+  1 edwops   abgrp      52539 Apr 14 16:16 20180414161603_S_EVT_ACT_FLD.log
-rw-rw----+  1 edwops   abgrp      52538 Apr 15 14:15 20180415141523_S_EVT_ACT_FLD.log
-rw-rw----+  1 edwops   abgrp      52576 Apr 16 15:38 20180416153808_S_EVT_ACT_FLD.log

Thanks.

A:

find . -ctime -10 -type f -print|xargs awk -F= '/Total Records Read/ {print $2}'|paste -sd+| bc

find . -ctime -10 -type f -print   get the filenames of files 10 days or younger in current working directory.  To run on a different directory replace . with the path
awk -F= '/Total Records Read/ {print $2}'  using = as a field seperator filter out the second half of any line containing the key phrase
Total Records Read
paste -sd+ add a plus sign
bc evaluate the stream of numbers and operators into a single answer

