Hello ,
I will need your help once again.
I have the following file:
cat file02.txt
PATTERN XXX.YYY.ZZZ. 500
ROW01 aaa. 300 XS 14
ROW 45 29 AS XD.FD.
PATTERN 500 ZZYN002
ROW gdf gsste
ALT 267 fhhfe.ddgdg.
PATTERN ERE.MAY. 280
PATTERRNTH 5000 rt.rt.
ROW SO a 678
PATTERN dsjsdh.sdshb 400 80
PATTERN ssds.500. 60
ROW 3389 LAST ROW
I'm trying to join all the lines which start with pattern
PATTERN
. Also I need to remove the last .
if occurs .
The desired results should be:
XXX.YYY.ZZZ 500 aaa 300 XS 14 45 29 AS XD.FD
500 ZZYN002 gdf gsste 267 fhhfe.ddgdg
ERE.MAY 280 5000 rt.rt SO a 678
dsjsdh.sdshb 400 80
ssds.500 60 3389 LAST ROW
I somehow managed to join the lines but cannot figure out how to get rid of the word PATTERN from output , remove the dot and delete the first word from the lines to be joined.
The command I came with is:
awk '/PATTERN/ && c{print c;c=""}{c=c $0" "}END{if(c) print c}' file02.txt
which produces (in red are the words / characters I don't need):
PATTERN XXX.YYY.ZZZ. 500 ROW01 aaa. 300 XS 14 ROW 45 29 AS XD.FD.
PATTERN 500 ZZYN002 ROW gdf gsste ALT 267 fhhfe.ddgdg.
PATTERN ERE.MAY. 280 PATTERRNTH 5000 rt.rt. ROW SO a 678
PATTERN dsjsdh.sdshb 400 80
PATTERN ssds.500. 60 ROW 3389 LAST ROW
Thanks in advance for your help.