to get two almost identical rows into one

Hi All,
I am having hard time in getting two almost identical rows into one, I know how to do if starting word is unique, anyhow this is my problem

Input File:
issue1 5167
dum 1 1 kkk 7888
dum 2 1 ffff 7888
dum 2 2 llll 7888
dum 3 1 eee 7888
issue2 7667
dum 2 1 jjjj 8999
dum 2 2 jjjj 8999
dum 3 pppp 8999

Output should be:
issue1 5167 1 kkk 2 ffff 2 llll 3 eee
issue2 7667 2 jjjj 3 pppp

Can someone give me a idea, of how to proceed with this, would be grately helpful if anyone can put all those ideas into writing...

Thanks,
Ricky

To keep the forums high quality for all users, please take the time to format your posts correctly.

  1. Use Code Tags when you post any code or data samples so others can easily read your code.
    You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags and by hand.)
  2. Avoid adding color or different fonts and font size to your posts.
    Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
  3. Be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
Reply With Quote

awk '{if(/issue/){if(NR>1){printf "\n%s",$0}else{printf}}else{printf " %s %s",$2,$4}}' file

Thanks alot danmero!!!!!

while(<DATA>){
	chomp;
	if(/^issue/){
		if($.==1){
			print $_;
		}
		else{
			print "\n$_";
		}
	}
	else{
		my @tmp=split;
		print join " ",(" ",@tmp[1,3]);
	}
}
__DATA__
issue1 5167
dum 1 1 kkk 7888
dum 2 1 ffff 7888
dum 2 2 llll 7888
dum 3 1 eee 7888
issue2 7667
dum 2 1 jjjj 8999
dum 2 2 jjjj 8999
dum 3 pppp 8999