Get counts for multiple files

How do get the counts by excluding header and tailer.

 wc -l customer_data*.0826
      31 customer_data_1.0826
      57 customer_data_2.0826
     456 customer_data_3.0826
     668 customer_data_4.0826
     789 customer_data_5.0826
    2344 customer_data_6.0826
   13457 customer_data_7.0826
   18112 customer_data_8.0826
   24876 customer_data_9.0826

Try this:

fileCount=0
wc -l customer_data*.0826 | while read lineCount FileName
do
      lineCountNHT=`expr ${lineCount} - 2`
      echo "FileName: [${FileName}] - LineCount: [${lineCountNHT}]".
done

I hope it helps!

Regards.

---------- Post updated at 13:22 ---------- Previous update was at 13:04 ----------

Change:

# From: wc -l customer_data*.0826 - To:
wc -l customer_data*.0826 | egrep -v 'total$'
 
for file in `ls -1 customer_data*.0826 `; do echo "$(expr `wc -l<$file` - 2 ) "$file"" ; done

Another way:

for mFile in `ls -1 customer_data*.0826`; do perl -lne '{$l++}; END {print "File: [$ARGV] [".($l-2)."]"}' $mFile; done

Thank You felipe and ygemici. That works. Since the file names remain constant ( the date alone changes for every three days) how can we modify the code to run these scripts for every three days?

If I understood your question correctly, I would schedule a crontab job and add a variable to the date in the file name.

Something like:

# customer_data*.MMDD
currDateMMDD=`date '+%m%d'`
for mFile in `ls -1 customer_data*.${currDateMMDD}`; do perl -lne '{$l++}; END {print "File: [$ARGV] [".($l-2)."]"}' $mFile; done

About the crontab, check these links:

vinturin thanks for your updates. My way of testing also same. But now i struked up with comparing the file count. I want to disaply the count only if all customer files exits in server with data say 10 files.
The variable files_total_cnt should have value 10 then get the counts from mall 10 files.

 #!/bin/ksh
path=/folder1/folder2/folder3/folder4/folder5/
cd $path
actualdate=`date +"%Y%m%d" -d "2 day ago"`
echo $actualdate
files_total_cnt=$(ls -l mcvp_fmc_usa_*.$actualdate) | some thing trying to get actual file cnt.....
if files_total_cnt > 10
then
for file in `ls -1 customer_data*.actualdate`; do echo "$(expr `wc -l<$file` - 2 ) "$file"" ; done
else
echo "some files are missing"
fi

note am getting count for 2 days old file so i coded in that way.

---------- Post updated at 02:53 PM ---------- Previous update was at 02:24 PM ----------

I got the solution. Thanks all.