Decrease the Line Gap in a files and Echo a strings

Hi Expert,

I have a file contains--

GET:RSUB:ISI,432350114637601;

RESP:0:MDN,9352608473:ISI,432350114637601:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,0:BOIC,0:BIRO,0:BORO,0:BOIH,0:BOS4,0:CLIP,1:CLIR,0:CFB,1;
GET:RSUB:ISI,432350114281653;

RESP:0:MDN,9358862438:ISI,432350114281653:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,0:BOIC,0:BIRO,0:BORO,0:BOIH,0:BOS4,0:CLIP,1:CLIR,0;
GET:RSUB:ISI,432350114478148;

RESP:0:MDN,9352866387:ISI,432350114478148:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,0:BOIC,0:BIRO,0:BORO,0:BOIH,0:BOS4,0:CLIP,1:CLIR,0:CFB,1;

I need to view it like below--

GET:RSUB:ISI,432350114637601;
RESP:0:MDN,9352608473:ISI,432350114637601:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,0:BOIC,0:BIRO,0:BORO,0:BOIH,0:BOS4,0:CLIP,1:CLIR,0:CFB,1;

GET:RSUB:ISI,432350114281653;
RESP:0:MDN,9358862438:ISI,432350114281653:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,0:BOIC,0:BIRO,0:BORO,0:BOIH,0:BOS4,0:CLIP,1:CLIR,0;

GET:RSUB:ISI,432350114478148;
RESP:0:MDN,9352866387:ISI,432350114478148:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,0:BOIC,0:BIRO,0:BORO,0:BOIH,0:BOS4,0:CLIP,1:CLIR,0:CFB,1

Total 3 Succsesful command
Total 0 Failed command

Note: If Resp:0 then succsseful
If Resp Not Equal 0 Failed.

Hi,

i don't know depending on what value you decide if a command failed
or not. But the following should give you the format you want.

awk '/GET/{s=$0;getline;getline;print s"\n" $0 "\n"}' file

HTH Chris

great its worked-
awk '/GET/{s=$0;getline;getline;print s"\n" $0 "\n"}' file

Depending on RESP:0 string i decide the command sucess. Here it is- If in the file there 3 "RESP:0" it means command successful 3.

If in the file "RESP:9*" or "RESP:1*" whathever other than 0 then i decide number of command failed.

Could you please get me the code of calculation Succsessful and Failed command.

many thanks again.

Not elegant but works:

awk '/GET/{s=$0;getline;getline;print s"\n" $0 "\n"};/RESP:0/{a++};/RESP:[^0]/{b++};END{print "Succesful: " a;print "Failed: " b}' file

YES buddy...its working..many thanks-

I have the below script--

    for line in \`cat /tmp/$file\`; do
            $SCRIPT\_DIR/run\_cmd\_in_EMA.sh 10.131.58.42 3300 lifetree life123

$line | grep -v "Enter command:" >> $REPORT_DIR/$file.TMP

    done

this code make file.tmp -- >$line | grep -v "Enter command:" >> $REPORT_DIR/$file.TMP

GET:RSUB:ISI,432350114637601;

RESP:0:MDN,9352608473:ISI,432350114637601:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,0:BOIC,0:BIRO,0: BORO,0:BOIH,0:BOS4,0:CLIP,1:CLIR,0:CFB,1;
SET:RSUB:ISI,432350114281653;

RESP:0:MDN,9358862438:ISI,432350114281653:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,0:BOIC,0:BIRO,0: BORO,0:BOIH,0:BOS4,0:CLIP,1:CLIR,0;
CREATE:RSUB:ISI,432350114478148;

RESP:0:MDN,9352866387:ISI,432350114478148:T11,1:T21,1:T22,1:B16,1:T62,1:BAIC,0:BAOC,0:BOIC,0:BIRO,0: BORO,0:BOIH,0:BOS4,0:CLIP,1:CLIR,0:CFB,1;

And on that *.tmp i will run your commands-

awk '/GET/{s=$0;getline;getline;print s"\n" $0 "\n"};/RESP:0/{a++};/RESP:[^0]/{b++};END{print "Succesful: " a;print "Failed: " b}' file.tmp

then how to use that in the script??

sed '/^$/d' file | awk '/GET/{print ""} 1'