Retrieve the record using 2,2 lines and display the ouput in columnwise

This is my file
-------------

Using index 8 for dump of table abd_det. (6101)
Dumped 0 records. (13932)
Using index 10 for dump of table abscc_det. (6101)
Dumped 0 records. (13932)
Using index 14 for dump of table absc_det. (6101)
Dumped 254365 records. (13932)
Using index 16 for dump of table absd_det. (6101)
Dumped 0 records. (13932)
Using index 18 for dump of table absi_mstr. (6101)
Dumped 0 records. (13932)
Using index 19 for dump of table absl_det. (6101)
Dumped 0 records. (13932)
Using index 21 for dump of table absr_det. (6101)
Dumped 66359 records. (13932)

I want the output like this:
-------------------------

abd_det - 0
abscc_det-0
absc_det-254365
absd_det-0
absi_mstr-0
absl_det-0
absr_det-66359
perl -ln0e 'while (/table (\w+).*\nDumped (\d+)/g){print "$1 - $2"}' file
 
nawk ' /Using index/{printf ("%s - ",$8);getline;print $2}' test
abd_det. - 0
abscc_det. - 0
absc_det. - 254365
absd_det. - 0
absi_mstr. - 0
absl_det. - 0
absr_det. - 66359

Another one:

awk -F"[. ]" '/Using/{printf $(NF-2) " - "} /Dumped/{print $2}' file
awk -F "[. ]" '{printf (NR%2?$(NF-2):"-" $2 RS)}' infile

Sed way..

sed '/_/{N;s/.* \(.*\)\. [^ ]* \([0-9]*\) .*/\1-\2/}' inputfile > outfile

Lot of Thanks for all the inputs.

One more way...

code:
-----
cat input | paste - - | awk ' { print $8 " - " $11 } '

1 Like
 
perl -ane 'if(/table/){$_=<>;@a=split;print "$F[7] - $a[1]\n"}' input

@jayan_jay Good solution. I didn't know about this.

Thanks a lot .. !!