Code:
echo -e "User_ID,Host_name,Date,Time,Code_302,Code_304,Code_305,"\
"Code_1,Code_2,Code_3,Code_7,Code_10,Code_18,Code_101,Code_201,"\
"Code_300,Code_301,Code_303,Code_306,Code_14,Code_9999,Code_19,"\
"Code_9,Code_11" > /path/Error_Report_$(date +%Y%m%d).csv
grep 'Pattern' Path/File_$(date +%Y%m%d)* |awk -F "|" '{
if($28~/ Pattern /) print substr($1,74,10)","substr($1,85,2)","$28;
else if($29~/ Pattern /) print substr($1,74,10)","substr($1,85,2)","$29;
else if($30~/ Pattern /) print substr($1,74,10)","substr($1,85,2)","$30}' |
cut -d, -f1,2,10 |
awk -F "," '{
if ($3~/ Error1/) print $1","$2","302;
else if ($3~/ Error2/) print $1","$2","304;
else if ($3~/ Error3/) print $1","$2","305;
else if ($3~/ Error4/) print $1","$2","1;
else if ($3~/ Error5/) print $1","$2","2;
else if ($3~/ Error6./) print $1","$2","3;
else if ($3~/ Error7./) print $1","$2","7;
else if ($3~/ Error 8/) print $1","$2","10;
else if ($3~/ Error./) print $1","$2","18;
else if ($3~/ Error 9/) print $1","$2","101;
else if ($3~/ Error 10/) print $1","$2","201;
else if ($3~/ Error11/) print $1","$2","300;
else if ($3~/ Error12/) print $1","$2","301;
else if ($3~/ Error13/) print $1","$2","303;
else if ($3~/ Error14/) print $1","$2","306;
else if ($3~/ Error15/) print $1","$2","14;
else if ($3~/ Error16/) print $1","$2","9999;
else if ($3~/ Error17./) print $1","$2","19;
else if ($3~/ Error18/) print $1","$2","9;
else if ($3~/ Error19/) print $1","$2","11}' | sort | uniq -c |
awk -F" " '{print $1","$2}' |
awk -F "," '{
if($4==302) print $2","$3","$1",,,,,,,,,,,,,,,,,,,";
else if($4==304) print $2","$3",,"$1",,,,,,,,,,,,,,,,,,";
else if($4==305) print $2","$3",,,"$1",,,,,,,,,,,,,,,,,";
else if($4==1) print $2","$3",,,,"$1",,,,,,,,,,,,,,,,";
else if($4==2) print $2","$3",,,,,"$1",,,,,,,,,,,,,,,";
else if($4==3) print $2","$3",,,,,,"$1",,,,,,,,,,,,,,";
else if($4==7) print $2","$3",,,,,,,"$1",,,,,,,,,,,,,";
else if($4==10) print $2","$3",,,,,,,,"$1",,,,,,,,,,,,";
else if($4==18) print $2","$3",,,,,,,,,"$1",,,,,,,,,,,";
else if($4==101) print $2","$3",,,,,,,,,,"$1",,,,,,,,,,";
else if($4==201) print $2","$3",,,,,,,,,,,"$1",,,,,,,,,";
else if($4==300) print $2","$3",,,,,,,,,,,,"$1",,,,,,,,";
else if($4==301) print $2","$3",,,,,,,,,,,,,"$1",,,,,,,";
else if($4==303) print $2","$3",,,,,,,,,,,,,,"$1",,,,,,";
else if($4==306) print $2","$3",,,,,,,,,,,,,,,"$1",,,,,";
else if($4==14) print $2","$3",,,,,,,,,,,,,,,,"$1",,,,";
else if($4==9999) print $2","$3",,,,,,,,,,,,,,,,,"$1",,,";
else if($4==19) print $2","$3",,,,,,,,,,,,,,,,,,"$1",";
else if($4==9) print $2","$3",,,,,,,,,,,,,,,,,,,"$1",";
else if($4==11) print $2","$3",,,,,,,,,,,,,,,,,,,,"$1}' |
awk -F"," '{
print "2001,Server1,"$1","$2":00:00,"$3","$4","$5","$6","$7",
"$8","$9","$10","$11","$12","$13","$14","$15","$16","$17",
"$18","$19","$20","$21","$22}' >>
/Path/Error_Report_$(date +%Y%m%d).csv