Generating a count report


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Generating a count report
# 1  
Old 07-23-2010
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.
Code:
 
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

Code:
 
 
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

Code:
 
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.

Last edited by pludi; 07-23-2010 at 04:54 AM.. Reason: No need for code tags on regular text
# 2  
Old 07-23-2010
Have a look here - printf
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to find the count of IP addresses that belong to different subnets and display the count?

Hi, I have a file with a list of bunch of IP addresses from different VLAN's . I am trying to find the list the number of each vlan occurence in the output Here is how my file looks like 1.1.1.1 1.1.1.2 1.1.1.3 1.1.2.1 1.1.2.2 1.1.3.1 1.1.3.2 1.1.3.3 1.1.3.4 So what I am trying... (2 Replies)
Discussion started by: new2prog
2 Replies

2. Shell Programming and Scripting

Compare file1 header count with file2 line count

What I'm trying to accomplish. I receive a Header and Detail file for daily processing. The detail file comes first which holds data, the header is a receipt of the detail file and has the detail files record count. Before processing the detail file I would like to put a wrapper around another... (4 Replies)
Discussion started by: pone2332
4 Replies

3. Shell Programming and Scripting

Comparing two files and generating the report

Hi All, What am trying to do is generate the report by compating two files. File A ----------- 111 22222 3333 222 55555 7777 File B ----------- 11A 22222 3333 333 55555 7778 Now the report should be as follows Added: 333 55555 7778 Removed: (6 Replies)
Discussion started by: Prashantckc
6 Replies

4. UNIX for Dummies Questions & Answers

How to count a string in a line and report it?

Hi, I have a text file full of such line (this is only 1 line, tab delimited): 1 108 . C T 553.90 . ... (19 Replies)
Discussion started by: a_bahreini
19 Replies

5. Shell Programming and Scripting

Novice in shell scripting - generating report

Hi I recently joined a project where I have been asked to generate a report using shell script accessing UNIX box. I have no idea on how to do it as I am a beginner and learning shell scripts. Suppose I have a XML: <XYZRequest> <effectiveDate>someDate</effectiveDate>... (2 Replies)
Discussion started by: vat1kor
2 Replies

6. Shell Programming and Scripting

generating report in Excel(Open office) using shell scripting

Hello All, I need to execute around 15 queries after which all data should come in Excel format. Executing 15 queries is not a problem. Problem is how to present/put data in excel. kindly suggest me how to start, what to study or what should i do. thanks, (1 Reply)
Discussion started by: shubham8787
1 Replies

7. Shell Programming and Scripting

count identical strings print last row and count

I have a sorted file like: Apple 3 Apple 5 Apple 8 Banana 2 Banana 3 Grape 31 Orange 7 Orange 13 I'd like to search $1 and if $1 is not the same as $1 in the previous row print that row and print the number of times $1 was found. so the output would look like: Apple 8 3 Banana... (2 Replies)
Discussion started by: dcfargo
2 Replies

8. Shell Programming and Scripting

Awk Script for generating a report

Hi all, I have a log file of the below format. 20081016:000042 asdflasjdf asljfljs asdflasjf safjl 20081016:000229 /lask/ajlsdf/askdfjsa 20081016:000229 /lashflas /askdfaslj hsfhsahf 20081016:000304 lasflasj ashfashd 20081016:000304 lajfasdf ashfashdfhs I need to generate a... (3 Replies)
Discussion started by: manoj.naidu
3 Replies

9. Shell Programming and Scripting

Parsing out the logs and generating report

My file will contain following(log.txt): start testcase: config loading ...... error XXXX ..... end testcase: config loading, result failed start testcase: ping check ..... error ZZZZZ ..... error AAAAA end testcase: Ping check, result failed I am expecting below output. ... (4 Replies)
Discussion started by: shellscripter
4 Replies

10. Shell Programming and Scripting

Generating a report -Formatted printing -Urgent

Hi, My aim is to generate a report using shell script. There are various formats fields coloumns etc. I want to print in a single line (row) but in different coloumn as given below: field1 field2 field3 field4 ....... ....... ...... ....... The spacing... (1 Reply)
Discussion started by: jisha
1 Replies
Login or Register to Ask a Question