Generate a Summary report | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Generate a Summary report

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-15-2013
Sakthikalluri Sakthikalluri is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 15 March 2013, 6:37 AM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Generate a Summary report

Hi All,

Script to meet my requirement might be simpler for UINIX experts..
I need to generate an summary report in .txt file using shell script

I have Reject directory in Unix server which contains all reject files for three diff categories- Presentation, Chapter and Scene

Following are the reject files

Reject_Lookup_Error_Presentation.csv
Reject_Lookup_Error_Chapter.csv
Reject_Lookup_Error_Scene.csv
Reject_Read_Error_Presentation.csv
Reject_Read_Error_Chapter.csv
Reject_Read_Error_Scene.csv

_____________________________________________________

Summary report Should be generated by identifying the file name and size. If any of the file size related to Presentation (*_Presentation.csv) is > 0 then. The summary report should display - "Presentation file has error in loading"
If all files related to presentation are 0 size then it should display "Presentation file loaded successfully"



Now my Summary report should look like below

_______________________________________

Presentation file has loaded successfully
Chapter file has error in loading
Scene file has error in loading

_____________________________________


Kindly help me with the code. I need it urgently.
Sponsored Links
    #2  
Old 03-15-2013
PikK45 PikK45 is offline
Registered User
 
Join Date: Jul 2012
Last Activity: 10 July 2014, 12:57 PM EDT
Location: Chennai
Posts: 567
Thanks: 43
Thanked 74 Times in 72 Posts

Code:
 
for file in Presentation Chapter Scene
do
count=$(find . -type f -prune -name "*_$file.csv" -size +0c -print | wc -l)
if [ $count -ne 0 ]; then
echo "$file file has error in loading" >> logfile
else
echo "$file file has loaded successfully" >> logfile
fi
done

Hope this helps
Sponsored Links
    #3  
Old 03-15-2013
ctsgnb ctsgnb is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 22 September 2014, 5:35 AM EDT
Location: France
Posts: 2,929
Thanks: 80
Thanked 624 Times in 596 Posts
@Pikk45

Your code cause the "Reject" directory to be scanned 3 times ...
you should change it to do it in one pass instead.
    #4  
Old 03-15-2013
PikK45 PikK45 is offline
Registered User
 
Join Date: Jul 2012
Last Activity: 10 July 2014, 12:57 PM EDT
Location: Chennai
Posts: 567
Thanks: 43
Thanked 74 Times in 72 Posts

Code:
 
find . -type f -prune \( -name "*_Presentation.csv" -o -name "*_Chapter.csv" -o -name "*_Scene.csv" \) -size +0c -print | awk ' /Presentation/{p=p+1}
/Chapter/{c=c+1}
/Scene/{s=s+1}
END {print p, c, s}' | read Presentation Chapter Scene
for count in $Presentation $Chapter $Scene
do
if [ $count -ne 0 ]; then
echo "$count file has error in loading" >> logfile
else
echo "$count file has loaded successfully" >> logfile
fi
done

@ctsgnb: Hope this does the trick
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Summary report csv file inMyZone35 Shell Programming and Scripting 2 01-20-2013 03:15 AM
Parse diff output into very detailed & summary report gvolpini Shell Programming and Scripting 0 02-08-2012 09:32 AM
generate a report gustave Shell Programming and Scripting 2 03-21-2010 04:44 AM
generate a report sailaja_80 Shell Programming and Scripting 8 08-21-2009 01:12 PM
how to add up a total in a summary report? xiaojesus Shell Programming and Scripting 16 04-23-2009 03:05 AM



All times are GMT -4. The time now is 08:25 PM.