generate a report

[LEFT]Hi

Please help me to resolve the below query.

My shell script has generated a file output.file like below
********************************
DROP TABLE GPS_CONTACT_DETAILS
DB20000I The SQL command completed successfully.
CREATE TABLE GPS_CONTACT_DETAILS ( CONTACT_ID VARCHAR(COUNTRY VARCHAR(20))
DB20000I The SQL command completed successfully.
********************************
Now

i have to generate a report like
GPS_CONTACT_DETAILS successfully

I am trying in all possible ways but not able to get this.
please help. Thanks for your help [/LEFT]

Post your attempts over here. Show us what you've tried so far.

tyler_durden

Thanks durden for your reply.
I am doing like below.

db2 -tvf "${var[Perforce_Script_Name]}" > $outdir
Is generating a file outdir liek this

DROP TABLE GPS_CONTACT_DETAILS
DB20000I The SQL command completed successfully.
CREATE TABLE GPS_CONTACT_DETAILS ( CONTACT_ID VARCHAR(30) )
DB20000I The SQL command completed successfully.

grep "successfully" $outdir >> $suc_Logfile
echo "${var[Object_Name]}" >> $suc_Logfile

generating file like this
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.

RMS_RPT_PERIOD_DIM

Now i need report.. like but i dotn know if we can do like this.

RMS_RPT_PERIOD_DIM Successful
abc successfull
as i was not able to do that.. i am tryign to send the lines where successfully word is not there to a different file

so i am trying like this...
grep -L "successfully" $suc_Logfile >> $Final_Suc
I tried to use awk command as well but was not successful

Thanks much for ur help

Your question and input data is way too confusing. Please wrap "code" tags around file contents, commands etc.

And show how the output you expect relates to your input file.

tyler_durden

My input file is like this.

DROP TABLE GPS_CONTACT_DETAILS
DB20000I The SQL command completed successfully.
CREATE TABLE GPS_CONTACT_DETAILS ( CONTACT_ID VARCHAR(30) )
DB20000I The SQL command completed successfully

Output file expecting is
DROP TABLE GPS_CONTACT_DETAILS successfully
CREATE TABLE GPS_CONTACT_DETAILS successfully

Hi Sailaja,

Below awk script can convert your sample input to sample output.
awk  ' $1 !~"^$" {print $1,$2,$3,"successfully."}' RS="successfully." file

But instead of success if there is any failure cases the script may give wrong result. Provide samples for failure also if any....

Regards,

Ranjith

Something like this :

awk '$0 ~ "successfully" { print q  " successfull" ;q=" ";next } $0 ~ "Fail"  { print q  "Failed" ;q=" ";next } { q = q " " $0 ; next } '  input_file.txt
awk '/TABLE/{n=$1FS$2FS$3;getline;print n FS $NF}' file

What about if the process fail ?

Hi all thanks for ur help. i am generating seperate success and failrue logs.

its workign now.

thank you