Generating a count report

Hi,
I want to generate a report for count mismatching.
Steps followed for creating a script

for file in

1). I have to fetch the file name from the checksum.out #customer_information_
2). Added Detail #customer_information_Detail
3). Check the file exist or not.
3.1.1)if the the file is present then sum of the first field from Trailer_Data.csv and store the value in to Acutal variable
3.1.2)count the customer_information_Detail.csv and stores into Generated
3.1.3) echo $Actual $Genrated Diff ($Actual-$Generated) "present"
3.2.1)If the file is not present then first field from Trailer_Data.csv and store the value in to Acutal variable
3.2.2)echo $Actual 0 0 "Not present"

For second loop
for file in
1). I have to fetch the file name from the checksum.out #product_information_
2). Added Detail #customer_information_Detail
3). Check the file exist or not.
3.1.1)if the the file is present then sum of the second field from Trailer_Data.csv and store the value in to Acutal variable
3.1.2)count the customer_information_Detail.csv and stores into Generated
3.1.3) echo $Actual $Genrated Diff ($Actual-$Generated) "present"
3.2.1)If the file is not present then first field from Trailer_Data.csv and store the value in to Acutal variable
3.2.2)echo $Actual 0 0 "Not present"

and so on...

I am unable to get the proper output when i run the below script.I feel that,unix is not that much user friendly for generating a report.

 
checksum.out
customer_information_
product_information_
sales_information_
due_information_
 
 
Trailer_Data.csv
5,4,0,3,20001010,1000
14,2,0,0,20001010,2000
 
 
echo "\n-----------------------------------------------------------------------------------------------------" >> Validation_Count_Match.out
echo "File Name\tAtcual value\tGenrated value\tDifference\tFile status" >> Validation_Count_Match.out
echo "-----------------------------------------------------------------------------------------------------\n" >> Validation_Count_Match.out
 
for i in 1 2 3 4 5
while read file; do
filename=$file"Detail"
if [ -e $TargetDir/$filename.csv ]
then
Actual=`awk -F"," '{x += $i} END {print x}' i=$i Trailer_Data.csv`
Generated=`wc -l $filename.csv |awk -F" " '{print $1}'`
echo $filename"\t: " $Actual"\t:"$Generated"\t" `expr $Actual - $Generated`"\tPresent" >> Validation_Count_Match.out
else
Actual=`awk -F"," '{x += $i} END {print x}' i=$i Trailer_Data.csv`
echo $filename"\t:"$Actual"\t:0\t"`expr $Actual - 0`"\tNot Present">> Validation_Count_Match.out
fi
done <checksum.out
done
 
Output
-----------------------------------------------------------------------------------------------------
File Name------------------------Atcual value-----Genrated value-----Difference-----File status
-----------------------------------------------------------------------------------------------------
 
customer_information_Detail 19 19 0 Present
product_information_Detail 6 6 0 Present
sales_information_Detail 0 0 0 Not present
due_information_Detail 3 3 0 Present

---------- Post updated 07-23-10 at 02:14 AM ---------- Previous update was 07-22-10 at 06:46 AM ----------

I am unable to find reporting command other then echo in unix.

Have a look here - man printf ("printf")